Skip to content Skip to sidebar Skip to footer

When I Add "method: Request" To Icalendar, Gmail Stops Recognizing As Event

I'm using iCalendar to schedule events for Gmail users. However, I want to be able to send updates, if/when the event changes. I read that I must use METHOD:REQUEST in order to all

Solution 1:

Ok - After many hours of reading RFC5546, Stackoverflow, and many other blogs, I finally have the answers.

Scope:

  1. Sending calendar invites to Gmail / Outlook / Privateemail (namecheap's email client)
  2. Email clients automatically recognizing .ics files and generating "accept" templates
  3. Events automatically appearing in client calendars as "tentative"
  4. Sending event revisions that automatically move client calendar events

There are two fundamental principles that are critical to making this work:

  1. The contents of the .ics file must very closely match the .ics file of the Gmail / Outlook community, this includes the parameters and the order of the parameters.

  2. The way the .ics file is attached to the email transmission is odd but critical: (a) the .ics file must be turned into 'base64', and (b) the headers of the file need to give a type: 'text/calendar;method=REQUEST;name="file.ics"'

Below I will give examples of each, which I hope save others time on this process.

.ics Content Example:

let iCal = 

`BEGIN:VCALENDARPRODID:-//Cratic//_Scheduler//ENVERSION:2.0CALSCALE:GREGORIANMETHOD:REQUESTBEGIN:VEVENTDTSTART:${DTStart}DTEND:${DTEnd}DTSTAMP:${DTStamp}ORGANIZER;CN=name:mailto:name@gmail.comUID:${event._id}@url.comATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=name@outlook.com;X-NUM-GUESTS=0:mailto:name@outlook.comCREATED:${DTStamp}DESCRIPTION:${event.body}LAST-MODIFIED:${DTStamp}LOCATION:${location}SEQUENCE:${sequence}STATUS:CONFIRMEDSUMMARY:${event.title}TRANSP:OPAQUEEND:VEVENTEND:VCALENDAR`

Please note: the above ordering is very important! And you must have no dead spaces around the text, even one extra space before or after will disrupt the email client. Also, this is a reusable dynamic iCal event template, as long as I keep a record of the event._id, I can use that _id to send revisions to all my clients.

Attaching .ics to Email Client:

// convert the invite to be base64 for attachmentconst buf = Buffer.from(iCal.toString(), 'utf-8');
const base64Cal = buf.toString('base64');

// build the emailconst sendEmail = async () => {
    const res = await client.transmissions.send({
        recipients: [{ address: 'name@outlook.com' }],
        content: {
          from: 'name@sparkmail.com',
          subject: req.body.a.title,
          text: req.body.a.body,
          attachments: [
            {
              name: 'invite.ics',
              type: 'text/calendar;method=REQUEST;name=\"invite.ics\"',
              data: base64Cal,
            },
          ],
        },
        options: { sandbox: false },
    });
}

// send the email
sendEmail();

Please note: The attachment type is critical for Outlook to recognize the event.

Although I'm sure there are other / better ways to integrate with these services, I found the above steps allowed me to accomplish my scope.

Post a Comment for "When I Add "method: Request" To Icalendar, Gmail Stops Recognizing As Event"