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

Visual Basic 6.0 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
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
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

 

 

 

(Visual Basic 6.0) 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

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

Dim http As New ChilkatHttp

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

Dim jsonToken As New ChilkatJsonObject
Dim success As Long
success = jsonToken.LoadFile("qa_data/tokens/outlookCalendar.json")
If (success = 0) Then
    Debug.Print jsonToken.LastErrorText
    Exit Sub
End If

http.AuthToken = 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.
Dim json As New ChilkatJsonObject
success = json.UpdateString("subject","Let's go for lunch")
success = json.UpdateString("body.contentType","HTML")
success = json.UpdateString("body.content","Does noon work for you?")
success = json.UpdateString("start.dateTime","2021-05-15T12:00:00")
success = json.UpdateString("start.timeZone","Pacific Standard Time")
success = json.UpdateString("end.dateTime","2021-05-15T14:00:00")
success = json.UpdateString("end.timeZone","Pacific Standard Time")
success = json.UpdateString("location.displayName","Harry's Bar")
success = json.UpdateString("attendees[0].emailAddress.address","samanthab@contoso.onmicrosoft.com")
success = json.UpdateString("attendees[0].emailAddress.name","Samantha Booth")
success = json.UpdateString("attendees[0].type","required")
success = json.UpdateBool("allowNewTimeProposals",1)

' Generate a UUID.
Dim crypt As New ChilkatCrypt2
success = json.UpdateString("transactionId",crypt.GenerateUuid())

' Add the "Prefer" request header.
http.SetRequestHeader "Prefer","outlook.timezone=""Pacific Standard Time"""

' Send the HTTP POST
Dim resp As ChilkatHttpResponse
Set resp = http.PostJson2("https://graph.microsoft.com/v1.0/me/events","application/json",json.Emit())
If (http.LastMethodSuccess <> 1) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Debug.Print "Response status code = " & resp.StatusCode

Dim jResp As New ChilkatJsonObject
success = jResp.Load(resp.BodyStr)
jResp.EmitCompact = 0
Debug.Print jResp.Emit()

' The send succeeded if the response status code = 201.
If (resp.StatusCode <> 201) Then
    Debug.Print "Failed"
    Exit Sub
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

Dim displayName As String
Dim locationType As String
Dim uniqueId As String
Dim uniqueIdType As String
Dim statusResponse As String
Dim statusTime As String
Dim emailAddressName As String
Dim emailAddressAddress As String

Dim odata_context As String
odata_context = jResp.StringOf("""@odata.context""")
Dim odata_etag As String
odata_etag = jResp.StringOf("""@odata.etag""")
Dim id As String
id = jResp.StringOf("id")
Dim createdDateTime As String
createdDateTime = jResp.StringOf("createdDateTime")
Dim lastModifiedDateTime As String
lastModifiedDateTime = jResp.StringOf("lastModifiedDateTime")
Dim changeKey As String
changeKey = jResp.StringOf("changeKey")
Dim transactionId As String
transactionId = jResp.StringOf("transactionId")
Dim originalStartTimeZone As String
originalStartTimeZone = jResp.StringOf("originalStartTimeZone")
Dim originalEndTimeZone As String
originalEndTimeZone = jResp.StringOf("originalEndTimeZone")
Dim iCalUId As String
iCalUId = jResp.StringOf("iCalUId")
Dim reminderMinutesBeforeStart As Long
reminderMinutesBeforeStart = jResp.IntOf("reminderMinutesBeforeStart")
Dim isReminderOn As Long
isReminderOn = jResp.BoolOf("isReminderOn")
Dim hasAttachments As Long
hasAttachments = jResp.BoolOf("hasAttachments")
Dim subject As String
subject = jResp.StringOf("subject")
Dim bodyPreview As String
bodyPreview = jResp.StringOf("bodyPreview")
Dim importance As String
importance = jResp.StringOf("importance")
Dim sensitivity As String
sensitivity = jResp.StringOf("sensitivity")
Dim isAllDay As Long
isAllDay = jResp.BoolOf("isAllDay")
Dim isCancelled As Long
isCancelled = jResp.BoolOf("isCancelled")
Dim isOrganizer As Long
isOrganizer = jResp.BoolOf("isOrganizer")
Dim responseRequested As Long
responseRequested = jResp.BoolOf("responseRequested")
Dim seriesMasterId As String
seriesMasterId = jResp.StringOf("seriesMasterId")
Dim showAs As String
showAs = jResp.StringOf("showAs")
Dim v_type As String
v_type = jResp.StringOf("type")
Dim webLink As String
webLink = jResp.StringOf("webLink")
Dim onlineMeetingUrl As String
onlineMeetingUrl = jResp.StringOf("onlineMeetingUrl")
Dim isOnlineMeeting As Long
isOnlineMeeting = jResp.BoolOf("isOnlineMeeting")
Dim onlineMeetingProvider As String
onlineMeetingProvider = jResp.StringOf("onlineMeetingProvider")
Dim allowNewTimeProposals As Long
allowNewTimeProposals = jResp.BoolOf("allowNewTimeProposals")
Dim isDraft As Long
isDraft = jResp.BoolOf("isDraft")
Dim hideAttendees As Long
hideAttendees = jResp.BoolOf("hideAttendees")
Dim recurrence As String
recurrence = jResp.StringOf("recurrence")
Dim onlineMeeting As String
onlineMeeting = jResp.StringOf("onlineMeeting")
Dim responseStatusResponse As String
responseStatusResponse = jResp.StringOf("responseStatus.response")
Dim responseStatusTime As String
responseStatusTime = jResp.StringOf("responseStatus.time")
Dim bodyContentType As String
bodyContentType = jResp.StringOf("body.contentType")
Dim bodyContent As String
bodyContent = jResp.StringOf("body.content")
Dim startDateTime As String
startDateTime = jResp.StringOf("start.dateTime")
Dim startTimeZone As String
startTimeZone = jResp.StringOf("start.timeZone")
Dim endDateTime As String
endDateTime = jResp.StringOf("end.dateTime")
Dim endTimeZone As String
endTimeZone = jResp.StringOf("end.timeZone")
Dim locationDisplayName As String
locationDisplayName = jResp.StringOf("location.displayName")
Dim locationLocationType As String
locationLocationType = jResp.StringOf("location.locationType")
Dim locationUniqueId As String
locationUniqueId = jResp.StringOf("location.uniqueId")
Dim locationUniqueIdType As String
locationUniqueIdType = jResp.StringOf("location.uniqueIdType")
Dim organizerEmailAddressName As String
organizerEmailAddressName = jResp.StringOf("organizer.emailAddress.name")
Dim organizerEmailAddressAddress As String
organizerEmailAddressAddress = jResp.StringOf("organizer.emailAddress.address")
Dim i As Long
i = 0
Dim count_i As Long
count_i = jResp.SizeOfArray("categories")
Do While i < count_i
    jResp.I = i
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("locations")
Do While i < count_i
    jResp.I = i
    displayName = jResp.StringOf("locations[i].displayName")
    locationType = jResp.StringOf("locations[i].locationType")
    uniqueId = jResp.StringOf("locations[i].uniqueId")
    uniqueIdType = jResp.StringOf("locations[i].uniqueIdType")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("attendees")
Do While i < count_i
    jResp.I = i
    v_type = jResp.StringOf("attendees[i].type")
    statusResponse = jResp.StringOf("attendees[i].status.response")
    statusTime = jResp.StringOf("attendees[i].status.time")
    emailAddressName = jResp.StringOf("attendees[i].emailAddress.name")
    emailAddressAddress = jResp.StringOf("attendees[i].emailAddress.address")
    i = i + 1
Loop

Debug.Print "Event created."

 

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