Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
724 views
in Technique[技术] by (71.8m points)

outlook - How to get ics calendar invitation to automatically add to calendar

I am generating .ics calendar invitation with the node package ical-generator and sending the attachment in an email via mandrill.

The .ics calendar invite contains information for one event at a specific time and date.

example generated file:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator//EN
METHOD:REQUEST
NAME: xxxx Events
X-WR-CALNAME: xxxxx
BEGIN:VEVENT
UID:5wzd@xxx.com
SEQUENCE:0
DTSTAMP:20180318T202459Z
DTSTART:20180330T230000Z
DTEND:20180330T230000Z
SUMMARY:test
LOCATION:test
DESCRIPTION:test
ORGANIZER;CN="info":mailto:info@xxxx.com
END:VEVENT
END:VCALENDAR

Right now, the user receives the calendar invitation as an attachment in the email and is able to add the event to their calendar if they open up the attachment and click on "add to calendar" (in outlook).

What changes do I need to make so that the calendar invite is automatically parsed by the mail client and added to the user's calendar (similar functionality is found in email confirmation from sites like meetup and eventbrite).

Not sure I have the context knowledge around how email clients, calendar systems or .ics files work to have a framework of how to approach this problem

Any suggestions or pointers to resources is greatly appreciated! Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to consider three points in order to add events automatically:

  1. Email Header
  2. iCalendar Method
  3. ATTENDEE information the "VEVENT" calendar component

Email Header

In order to get the email client to parse correctly the attached .ics file, you should add the scheduling method and MIME information to the email headers. This is specified by the iCalendar Message-Based Interoperability Protocol (RFC 2447).

For this reason, your header should include Content-Type, Content-Transfer-Encoding and Content-Disposition as specified in the following example:

Content-Type: text/calendar; charset=utf-8; method=REQUEST; name=invite.ics'
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename=invite.ics

iCalendar Method

When used in a MIME message entity, the value of "METHOD" must be the same as the Content-Type "method". This can only appear once within the iCalendar object. The value of this field is defined by the iCalendar Transport-Independent Interoperability Protocol (iTIP) (RFC 5546). In order to request for a meeting, the value should be "REQUEST".

METHOD:REQUEST

ATTENDEE information the "VEVENT" calendar component

This property is the state of a particular "Attendee" relative to an event. It is used for scheduling and is defined by the "PARTSTAT" parameter in the "ATTENDEE" property for each attendee.

ATTENDEE;PARTSTAT=ACCEPTED;CN="Jane 
 Doe";EMAIL=jdoe@gmail.com:MAILTO:jdoe@gmailcom

Here is an example of a minimal .ics file:

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
UID:<unique-id>@<site>.com
DTSTAMP:20210605T073803Z
DTSTART;TZID=America/Guayaquil:20210614T030000
DTEND;TZID=America/Guayaquil:20210614T040000
SUMMARY:My Event
ORGANIZER;CN="Juan Perez":mailto:jperez@organizer.com
ATTENDEE;PARTSTAT=ACCEPTED;CN="Jane 
 Doe";EMAIL=jdoe@gmail.com:MAILTO:jdoe@gmailcom
URL;VALUE=URI:https://<site>.com/event/5960492994476830083
END:VEVENT
END:VCALENDAR

For more details, please take a look at my gist.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...