DataFlex
DataFlex
Add an iCalendar Meeting Invitation to an Email
See more Email Object Examples
Demonstrates the Chilkat Email.AddiCalendarAlternativeBody method, which adds or replaces an iCalendar body as a text/calendar alternative. The first argument is the iCalendar content and the second is the iCalendar method (such as REQUEST, REPLY, or CANCEL). If an iCalendar alternative already exists it is replaced, so repeated calls leave at most one. This example attaches a simple meeting request.
Background: When you receive a calendar invite that your mail client shows with Accept/Decline buttons, it arrives as an iCalendar (
.ics) body carried in the message as a text/calendar alternative. The METHOD — REQUEST to invite, CANCEL to withdraw, REPLY to respond — tells the recipient's client how to treat it. Delivering it as an alternative means clients that understand calendars show the invite UI, while others fall back to the plain-text or HTML body.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoEmail
String sIcal
Boolean iSuccess
Integer iTemp1
// Demonstrates the AddiCalendarAlternativeBody method, which adds (or replaces) an
// iCalendar body as a text/calendar alternative. The first argument is the iCalendar content and the second
// is the iCalendar method (such as REQUEST, REPLY, or CANCEL).
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "Meeting invitation"
Send ComSetTextBody To hoEmail "You are invited to the Project Sync meeting." "text/plain"
// The iCalendar (VCALENDAR) content. In practice this is generated iCalendar text.
Move "BEGIN:VCALENDAR" + (character(13)) + (character(10)) + "VERSION:2.0" + (character(13)) + (character(10)) + "METHOD:REQUEST" + (character(13)) + (character(10)) + "BEGIN:VEVENT" + (character(13)) + (character(10)) + "SUMMARY:Project Sync" + (character(13)) + (character(10)) + "DTSTART:20260720T160000Z" + (character(13)) + (character(10)) + "DTEND:20260720T163000Z" + (character(13)) + (character(10)) + "END:VEVENT" + (character(13)) + (character(10)) + "END:VCALENDAR" + (character(13)) + (character(10)) To sIcal
// Add the iCalendar as a text/calendar alternative using the REQUEST method.
Get ComAddiCalendarAlternativeBody Of hoEmail sIcal "REQUEST" To iSuccess
Get ComNumAlternatives Of hoEmail To iTemp1
Showln "NumAlternatives = " iTemp1
End_Procedure