Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) Outlook Calendar Create an Event

See more Outlook Calendar Examples

Create 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

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
Token    Handle hoJsonToken
    Boolean iSuccess
    Handle hoJson
    Handle hoCrypt
    Variant vResp
    Handle hoResp
    Handle hoJResp
    String sDisplayName
    String sLocationType
    String sUniqueId
    String sUniqueIdType
    String sStatusResponse
    String sStatusTime
    String sEmailAddressName
    String sEmailAddressAddress
    String sOdata_context
    String sOdata_etag
    String sId
    String sCreatedDateTime
    String sLastModifiedDateTime
    String sChangeKey
    String sTransactionId
    String sOriginalStartTimeZone
    String sOriginalEndTimeZone
    String sICalUId
    Integer iReminderMinutesBeforeStart
    Boolean iIsReminderOn
    Boolean iHasAttachments
    String sSubject
    String sBodyPreview
    String sImportance
    String sSensitivity
    Boolean iIsAllDay
    Boolean iIsCancelled
    Boolean iIsOrganizer
    Boolean iResponseRequested
    String sSeriesMasterId
    String sShowAs
    String sV_type
    String sWebLink
    String sOnlineMeetingUrl
    Boolean iIsOnlineMeeting
    String sOnlineMeetingProvider
    Boolean iAllowNewTimeProposals
    Boolean iIsDraft
    Boolean iHideAttendees
    String sRecurrence
    String sOnlineMeeting
    String sResponseStatusResponse
    String sResponseStatusTime
    String sBodyContentType
    String sBodyContent
    String sStartDateTime
    String sStartTimeZone
    String sEndDateTime
    String sEndTimeZone
    String sLocationDisplayName
    String sLocationLocationType
    String sLocationUniqueId
    String sLocationUniqueIdType
    String sOrganizerEmailAddressName
    String sOrganizerEmailAddressAddress
    Integer i
    Integer iCount_i
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // Use your previously obtained access token here: Get Outlook Calendar OAuth2 Access Token (Azure AD v2.0 Endpoint).

    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken
    If (Not(IsComObjectCreated(hoJsonToken))) Begin
        Send CreateComObject of hoJsonToken
    End
    Get ComLoadFile Of hoJsonToken "qa_data/tokens/outlookCalendar.json" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoJsonToken To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStringOf Of hoJsonToken "access_token" To sTemp1
    Set ComAuthToken Of hoHttp To sTemp1

    // 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.
    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "subject" "Let's go for lunch" To iSuccess
    Get ComUpdateString Of hoJson "body.contentType" "HTML" To iSuccess
    Get ComUpdateString Of hoJson "body.content" "Does noon work for you?" To iSuccess
    Get ComUpdateString Of hoJson "start.dateTime" "2021-05-15T12:00:00" To iSuccess
    Get ComUpdateString Of hoJson "start.timeZone" "Pacific Standard Time" To iSuccess
    Get ComUpdateString Of hoJson "end.dateTime" "2021-05-15T14:00:00" To iSuccess
    Get ComUpdateString Of hoJson "end.timeZone" "Pacific Standard Time" To iSuccess
    Get ComUpdateString Of hoJson "location.displayName" "Harry's Bar" To iSuccess
    Get ComUpdateString Of hoJson "attendees[0].emailAddress.address" "samanthab@contoso.onmicrosoft.com" To iSuccess
    Get ComUpdateString Of hoJson "attendees[0].emailAddress.name" "Samantha Booth" To iSuccess
    Get ComUpdateString Of hoJson "attendees[0].type" "required" To iSuccess
    Get ComUpdateBool Of hoJson "allowNewTimeProposals" True To iSuccess

    // Generate a UUID.
    Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt
    If (Not(IsComObjectCreated(hoCrypt))) Begin
        Send CreateComObject of hoCrypt
    End
    Get ComGenerateUuid Of hoCrypt To sTemp1
    Get ComUpdateString Of hoJson "transactionId" sTemp1 To iSuccess

    // Add the "Prefer" request header.
    Send ComSetRequestHeader To hoHttp "Prefer" 'outlook.timezone="Pacific Standard Time"'

    // Send the HTTP POST
    Get ComEmit Of hoJson To sTemp1
    Get ComPostJson2 Of hoHttp "https://graph.microsoft.com/v1.0/me/events" "application/json" sTemp1 To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStatusCode Of hoResp To iTemp1
    Showln "Response status code = " iTemp1

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get ComBodyStr Of hoResp To sTemp1
    Get ComLoad Of hoJResp sTemp1 To iSuccess
    Set ComEmitCompact Of hoJResp To False
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Send Destroy of hoResp

    // The send succeeded if the response status code = 201.
    Get ComStatusCode Of hoResp To iTemp1
    If (iTemp1 <> 201) Begin
        Showln "Failed"
        Procedure_Return
    End

    // 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

    Get ComStringOf Of hoJResp '"@odata.context"' To sOdata_context
    Get ComStringOf Of hoJResp '"@odata.etag"' To sOdata_etag
    Get ComStringOf Of hoJResp "id" To sId
    Get ComStringOf Of hoJResp "createdDateTime" To sCreatedDateTime
    Get ComStringOf Of hoJResp "lastModifiedDateTime" To sLastModifiedDateTime
    Get ComStringOf Of hoJResp "changeKey" To sChangeKey
    Get ComStringOf Of hoJResp "transactionId" To sTransactionId
    Get ComStringOf Of hoJResp "originalStartTimeZone" To sOriginalStartTimeZone
    Get ComStringOf Of hoJResp "originalEndTimeZone" To sOriginalEndTimeZone
    Get ComStringOf Of hoJResp "iCalUId" To sICalUId
    Get ComIntOf Of hoJResp "reminderMinutesBeforeStart" To iReminderMinutesBeforeStart
    Get ComBoolOf Of hoJResp "isReminderOn" To iIsReminderOn
    Get ComBoolOf Of hoJResp "hasAttachments" To iHasAttachments
    Get ComStringOf Of hoJResp "subject" To sSubject
    Get ComStringOf Of hoJResp "bodyPreview" To sBodyPreview
    Get ComStringOf Of hoJResp "importance" To sImportance
    Get ComStringOf Of hoJResp "sensitivity" To sSensitivity
    Get ComBoolOf Of hoJResp "isAllDay" To iIsAllDay
    Get ComBoolOf Of hoJResp "isCancelled" To iIsCancelled
    Get ComBoolOf Of hoJResp "isOrganizer" To iIsOrganizer
    Get ComBoolOf Of hoJResp "responseRequested" To iResponseRequested
    Get ComStringOf Of hoJResp "seriesMasterId" To sSeriesMasterId
    Get ComStringOf Of hoJResp "showAs" To sShowAs
    Get ComStringOf Of hoJResp "type" To sV_type
    Get ComStringOf Of hoJResp "webLink" To sWebLink
    Get ComStringOf Of hoJResp "onlineMeetingUrl" To sOnlineMeetingUrl
    Get ComBoolOf Of hoJResp "isOnlineMeeting" To iIsOnlineMeeting
    Get ComStringOf Of hoJResp "onlineMeetingProvider" To sOnlineMeetingProvider
    Get ComBoolOf Of hoJResp "allowNewTimeProposals" To iAllowNewTimeProposals
    Get ComBoolOf Of hoJResp "isDraft" To iIsDraft
    Get ComBoolOf Of hoJResp "hideAttendees" To iHideAttendees
    Get ComStringOf Of hoJResp "recurrence" To sRecurrence
    Get ComStringOf Of hoJResp "onlineMeeting" To sOnlineMeeting
    Get ComStringOf Of hoJResp "responseStatus.response" To sResponseStatusResponse
    Get ComStringOf Of hoJResp "responseStatus.time" To sResponseStatusTime
    Get ComStringOf Of hoJResp "body.contentType" To sBodyContentType
    Get ComStringOf Of hoJResp "body.content" To sBodyContent
    Get ComStringOf Of hoJResp "start.dateTime" To sStartDateTime
    Get ComStringOf Of hoJResp "start.timeZone" To sStartTimeZone
    Get ComStringOf Of hoJResp "end.dateTime" To sEndDateTime
    Get ComStringOf Of hoJResp "end.timeZone" To sEndTimeZone
    Get ComStringOf Of hoJResp "location.displayName" To sLocationDisplayName
    Get ComStringOf Of hoJResp "location.locationType" To sLocationLocationType
    Get ComStringOf Of hoJResp "location.uniqueId" To sLocationUniqueId
    Get ComStringOf Of hoJResp "location.uniqueIdType" To sLocationUniqueIdType
    Get ComStringOf Of hoJResp "organizer.emailAddress.name" To sOrganizerEmailAddressName
    Get ComStringOf Of hoJResp "organizer.emailAddress.address" To sOrganizerEmailAddressAddress
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "categories" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "locations" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "locations[i].displayName" To sDisplayName
        Get ComStringOf Of hoJResp "locations[i].locationType" To sLocationType
        Get ComStringOf Of hoJResp "locations[i].uniqueId" To sUniqueId
        Get ComStringOf Of hoJResp "locations[i].uniqueIdType" To sUniqueIdType
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "attendees" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "attendees[i].type" To sV_type
        Get ComStringOf Of hoJResp "attendees[i].status.response" To sStatusResponse
        Get ComStringOf Of hoJResp "attendees[i].status.time" To sStatusTime
        Get ComStringOf Of hoJResp "attendees[i].emailAddress.name" To sEmailAddressName
        Get ComStringOf Of hoJResp "attendees[i].emailAddress.address" To sEmailAddressAddress
        Move (i + 1) To i
    Loop

    Showln "Event created."


End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.