You need to consider three points in order to add events automatically:
- Email Header
- iCalendar Method
- 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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…