Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Outlook Calendar Create an EventSee more Outlook Calendar ExamplesCreate an event in the specified time zone, and assign the event an optional transactionId value. For more information, see https://docs.microsoft.com/en-us/graph/api/user-post-events?view=graph-rest-1.0&tabs=http#example-1-create-an-event-in-the-specified-time-zone-and-assign-the-event-an-optional-transactionid-value
integer li_rc oleobject loo_Http oleobject loo_JsonToken integer li_Success oleobject loo_Json oleobject loo_Crypt oleobject loo_Resp oleobject loo_JResp string ls_DisplayName string ls_LocationType string ls_UniqueId string ls_UniqueIdType string ls_StatusResponse string ls_StatusTime string ls_EmailAddressName string ls_EmailAddressAddress string ls_Odata_context string ls_Odata_etag string ls_Id string ls_CreatedDateTime string ls_LastModifiedDateTime string ls_ChangeKey string ls_TransactionId string ls_OriginalStartTimeZone string ls_OriginalEndTimeZone string ls_ICalUId integer li_ReminderMinutesBeforeStart integer li_IsReminderOn integer li_HasAttachments string ls_Subject string ls_BodyPreview string ls_Importance string ls_Sensitivity integer li_IsAllDay integer li_IsCancelled integer li_IsOrganizer integer li_ResponseRequested string ls_SeriesMasterId string ls_ShowAs string ls_V_type string ls_WebLink string ls_OnlineMeetingUrl integer li_IsOnlineMeeting string ls_OnlineMeetingProvider integer li_AllowNewTimeProposals integer li_IsDraft integer li_HideAttendees string ls_Recurrence string ls_OnlineMeeting string ls_ResponseStatusResponse string ls_ResponseStatusTime string ls_BodyContentType string ls_BodyContent string ls_StartDateTime string ls_StartTimeZone string ls_EndDateTime string ls_EndTimeZone string ls_LocationDisplayName string ls_LocationLocationType string ls_LocationUniqueId string ls_LocationUniqueIdType string ls_OrganizerEmailAddressName string ls_OrganizerEmailAddressAddress integer i integer li_Count_i // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Use your previously obtained access token here: Get Outlook Calendar OAuth2 Access Token (Azure AD v2.0 Endpoint). loo_JsonToken = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject") li_Success = loo_JsonToken.LoadFile("qa_data/tokens/outlookCalendar.json") if li_Success = 0 then Write-Debug loo_JsonToken.LastErrorText destroy loo_Http destroy loo_JsonToken return end if loo_Http.AuthToken = loo_JsonToken.StringOf("access_token") // Send the following POST: // POST https://graph.microsoft.com/v1.0/me/events // Prefer: outlook.timezone="Pacific Standard Time" // Content-type: application/json // // { // "subject": "Let's go for lunch", // "body": { // "contentType": "HTML", // "content": "Does noon work for you?" // }, // "start": { // "dateTime": "2017-04-15T12:00:00", // "timeZone": "Pacific Standard Time" // }, // "end": { // "dateTime": "2017-04-15T14:00:00", // "timeZone": "Pacific Standard Time" // }, // "location":{ // "displayName":"Harry's Bar" // }, // "attendees": [ // { // "emailAddress": { // "address":"samanthab@contoso.onmicrosoft.com", // "name": "Samantha Booth" // }, // "type": "required" // } // ], // "allowNewTimeProposals": true, // "transactionId":"7E163156-7762-4BEB-A1C6-729EA81755A7" // } // Build the JSON body of the POST. loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateString("subject","Let's go for lunch") loo_Json.UpdateString("body.contentType","HTML") loo_Json.UpdateString("body.content","Does noon work for you?") loo_Json.UpdateString("start.dateTime","2021-05-15T12:00:00") loo_Json.UpdateString("start.timeZone","Pacific Standard Time") loo_Json.UpdateString("end.dateTime","2021-05-15T14:00:00") loo_Json.UpdateString("end.timeZone","Pacific Standard Time") loo_Json.UpdateString("location.displayName","Harry's Bar") loo_Json.UpdateString("attendees[0].emailAddress.address","samanthab@contoso.onmicrosoft.com") loo_Json.UpdateString("attendees[0].emailAddress.name","Samantha Booth") loo_Json.UpdateString("attendees[0].type","required") loo_Json.UpdateBool("allowNewTimeProposals",1) // Generate a UUID. loo_Crypt = create oleobject // Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2") loo_Json.UpdateString("transactionId",loo_Crypt.GenerateUuid()) // Add the "Prefer" request header. loo_Http.SetRequestHeader("Prefer","outlook.timezone=~"Pacific Standard Time~"") // Send the HTTP POST loo_Resp = loo_Http.PostJson2("https://graph.microsoft.com/v1.0/me/events","application/json",loo_Json.Emit()) if loo_Http.LastMethodSuccess <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_JsonToken destroy loo_Json destroy loo_Crypt return end if Write-Debug "Response status code = " + string(loo_Resp.StatusCode) loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.Load(loo_Resp.BodyStr) loo_JResp.EmitCompact = 0 Write-Debug loo_JResp.Emit() destroy loo_Resp // The send succeeded if the response status code = 201. if loo_Resp.StatusCode <> 201 then Write-Debug "Failed" destroy loo_Http destroy loo_JsonToken destroy loo_Json destroy loo_Crypt destroy loo_JResp return end if // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('user%40example.com')/events/$entity", // "@odata.etag": "W/\"5+vF7TKKdE6bGCRqXyl2PQAEaGQgcw==\"", // "id": "AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgENAAAA5_vF7TKKdE6bGCRqXyl2PQAEaDkEcAAAAA==", // "createdDateTime": "2021-04-18T23:38:52.1979259Z", // "lastModifiedDateTime": "2021-04-18T23:38:53.3747647Z", // "changeKey": "5+vF7TKKdE6bGCRqXyl2PQAEaGQgcw==", // "categories": [ // ], // "transactionId": "1d12b565-3ca3-4ed8-b3f9-e8a14ac3ac17", // "originalStartTimeZone": "Pacific Standard Time", // "originalEndTimeZone": "Pacific Standard Time", // "iCalUId": "040000008200E00074C5B7101A82E00800000000EF0328FDAB34D7010000000000000000100000004478DD5948382543AFD1B52C25E88C02", // "reminderMinutesBeforeStart": 15, // "isReminderOn": true, // "hasAttachments": false, // "subject": "Let's go for lunch", // "bodyPreview": "Does noon work for you?", // "importance": "normal", // "sensitivity": "normal", // "isAllDay": false, // "isCancelled": false, // "isOrganizer": true, // "responseRequested": true, // "seriesMasterId": null, // "showAs": "busy", // "type": "singleInstance", // "webLink": "https://outlook.live.com/owa/?itemid=AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5%2BvF7TKKdE6bGCRqXyl2PQAAAgENAAAA5%2BvF7TKKdE6bGCRqXyl2PQAEaDkEcAAAAA%3D%3D&exvsurl=1&path=/calendar/item", // "onlineMeetingUrl": null, // "isOnlineMeeting": false, // "onlineMeetingProvider": "unknown", // "allowNewTimeProposals": true, // "isDraft": false, // "hideAttendees": false, // "recurrence": null, // "onlineMeeting": null, // "responseStatus": { // "response": "organizer", // "time": "0001-01-01T00:00:00Z" // }, // "body": { // "contentType": "html", // "content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nDoes noon work for you?\r\n</body>\r\n</html>\r\n" // }, // "start": { // "dateTime": "2021-05-15T12:00:00.0000000", // "timeZone": "Pacific Standard Time" // }, // "end": { // "dateTime": "2021-05-15T14:00:00.0000000", // "timeZone": "Pacific Standard Time" // }, // "location": { // "displayName": "Harry's Bar", // "locationType": "default", // "uniqueId": "Harry's Bar", // "uniqueIdType": "private" // }, // "locations": [ // { // "displayName": "Harry's Bar", // "locationType": "default", // "uniqueId": "Harry's Bar", // "uniqueIdType": "private" // } // ], // "attendees": [ // { // "type": "required", // "status": { // "response": "none", // "time": "0001-01-01T00:00:00Z" // }, // "emailAddress": { // "name": "Samantha Booth", // "address": "samanthab@contoso.onmicrosoft.com" // } // } // ], // "organizer": { // "emailAddress": { // "name": "John Doe", // "address": "outlook_3A33FCEB9B74CC15@outlook.com" // } // } // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON ls_Odata_context = loo_JResp.StringOf("~"@odata.context~"") ls_Odata_etag = loo_JResp.StringOf("~"@odata.etag~"") ls_Id = loo_JResp.StringOf("id") ls_CreatedDateTime = loo_JResp.StringOf("createdDateTime") ls_LastModifiedDateTime = loo_JResp.StringOf("lastModifiedDateTime") ls_ChangeKey = loo_JResp.StringOf("changeKey") ls_TransactionId = loo_JResp.StringOf("transactionId") ls_OriginalStartTimeZone = loo_JResp.StringOf("originalStartTimeZone") ls_OriginalEndTimeZone = loo_JResp.StringOf("originalEndTimeZone") ls_ICalUId = loo_JResp.StringOf("iCalUId") li_ReminderMinutesBeforeStart = loo_JResp.IntOf("reminderMinutesBeforeStart") li_IsReminderOn = loo_JResp.BoolOf("isReminderOn") li_HasAttachments = loo_JResp.BoolOf("hasAttachments") ls_Subject = loo_JResp.StringOf("subject") ls_BodyPreview = loo_JResp.StringOf("bodyPreview") ls_Importance = loo_JResp.StringOf("importance") ls_Sensitivity = loo_JResp.StringOf("sensitivity") li_IsAllDay = loo_JResp.BoolOf("isAllDay") li_IsCancelled = loo_JResp.BoolOf("isCancelled") li_IsOrganizer = loo_JResp.BoolOf("isOrganizer") li_ResponseRequested = loo_JResp.BoolOf("responseRequested") ls_SeriesMasterId = loo_JResp.StringOf("seriesMasterId") ls_ShowAs = loo_JResp.StringOf("showAs") ls_V_type = loo_JResp.StringOf("type") ls_WebLink = loo_JResp.StringOf("webLink") ls_OnlineMeetingUrl = loo_JResp.StringOf("onlineMeetingUrl") li_IsOnlineMeeting = loo_JResp.BoolOf("isOnlineMeeting") ls_OnlineMeetingProvider = loo_JResp.StringOf("onlineMeetingProvider") li_AllowNewTimeProposals = loo_JResp.BoolOf("allowNewTimeProposals") li_IsDraft = loo_JResp.BoolOf("isDraft") li_HideAttendees = loo_JResp.BoolOf("hideAttendees") ls_Recurrence = loo_JResp.StringOf("recurrence") ls_OnlineMeeting = loo_JResp.StringOf("onlineMeeting") ls_ResponseStatusResponse = loo_JResp.StringOf("responseStatus.response") ls_ResponseStatusTime = loo_JResp.StringOf("responseStatus.time") ls_BodyContentType = loo_JResp.StringOf("body.contentType") ls_BodyContent = loo_JResp.StringOf("body.content") ls_StartDateTime = loo_JResp.StringOf("start.dateTime") ls_StartTimeZone = loo_JResp.StringOf("start.timeZone") ls_EndDateTime = loo_JResp.StringOf("end.dateTime") ls_EndTimeZone = loo_JResp.StringOf("end.timeZone") ls_LocationDisplayName = loo_JResp.StringOf("location.displayName") ls_LocationLocationType = loo_JResp.StringOf("location.locationType") ls_LocationUniqueId = loo_JResp.StringOf("location.uniqueId") ls_LocationUniqueIdType = loo_JResp.StringOf("location.uniqueIdType") ls_OrganizerEmailAddressName = loo_JResp.StringOf("organizer.emailAddress.name") ls_OrganizerEmailAddressAddress = loo_JResp.StringOf("organizer.emailAddress.address") i = 0 li_Count_i = loo_JResp.SizeOfArray("categories") do while i < li_Count_i loo_JResp.I = i i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("locations") do while i < li_Count_i loo_JResp.I = i ls_DisplayName = loo_JResp.StringOf("locations[i].displayName") ls_LocationType = loo_JResp.StringOf("locations[i].locationType") ls_UniqueId = loo_JResp.StringOf("locations[i].uniqueId") ls_UniqueIdType = loo_JResp.StringOf("locations[i].uniqueIdType") i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("attendees") do while i < li_Count_i loo_JResp.I = i ls_V_type = loo_JResp.StringOf("attendees[i].type") ls_StatusResponse = loo_JResp.StringOf("attendees[i].status.response") ls_StatusTime = loo_JResp.StringOf("attendees[i].status.time") ls_EmailAddressName = loo_JResp.StringOf("attendees[i].emailAddress.name") ls_EmailAddressAddress = loo_JResp.StringOf("attendees[i].emailAddress.address") i = i + 1 loop Write-Debug "Event created." destroy loo_Http destroy loo_JsonToken destroy loo_Json destroy loo_Crypt destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.