本文介绍了如何获取 ics 日历邀请以自动添加到日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用节点包 ical-generator 生成 .ics 日历邀请,并通过 mandrill 在电子邮件中发送附件.

.ics 日历邀请包含特定时间和日期的一个事件的信息.

示例生成文件:

BEGIN:VCALENDAR版本:2.0PRODID:-//sebbo.net//ical-generator//EN方法:请求名称: xxxx 活动X-WR-CALNAME: xxxxx开始:事件UID:5wzd@xxx.com序列:0DTSTAMP:20180318T202459ZDTSTART:20180330T230000ZDTEND:20180330T230000Z摘要:测试地点:测试描述:测试组织者;CN="info":mailto:info@xxxx.com结束:事件结束:VCALENDAR

现在,用户在电子邮件中以附件形式收到日历邀请,如果他们打开附件并单击添加到日历"(在 Outlook 中),就可以将事件添加到他们的日历中.

我需要进行哪些更改,以便邮件客户端自动解析日历邀请并将其添加到用户的日历中(类似的功能可以在来自诸如 meetup 和 eventbrite 的网站的电子邮件确认中找到).

不确定我是否具备有关电子邮件客户端、日历系统或 .ics 文件如何工作的上下文知识,以制定解决此问题的框架

非常感谢任何有关资源的建议或指针!谢谢!

解决方案

自动添加事件需要考虑三点:

  1. 电子邮件标题
  2. iCalendar 方法
  3. 参加者信息VEVENT";日历组件

电子邮件标题

为了让电子邮件客户端正确解析附加的 .ics 文件,您应该将调度方法和 MIME 信息添加到电子邮件标头.这由 iCalendar 基于消息的互操作性协议 (RFC 2447) 指定.p>

因此,您的标题应包含 Content-Type,内容传输编码Content-Disposition 如下例所示:

内容类型:文本/日历;字符集=utf-8;方法=请求;名称=invite.ics'内容传输编码:Base64内容处置:附件;文件名=invite.ics

iCalendar 方法

当在 MIME 消息实体中使用时,METHOD"的值是必须与 Content-Type方法"相同.这只能在 iCalendar 对象中出现一次.此字段的值由 iCalendar 传输独立互操作性协议 (iTIP) 定义(RFC 5546).为了请求会议,值应该是 "REQUEST";.

方法:请求

参加者信息VEVENT";日历组件

此属性是特定参加者"的状态.相对于一个事件.它用于调度并由PARTSTAT"定义.ATTENDEE"中的参数;每位与会者的财产.

ATTENDEE;PARTSTAT=ACCEPTED;CN="Jane美国能源部EMAIL=jdoe@gmail.com:MAILTO:jdoe@gmailcom

这是一个最小的 .ics 文件示例:

BEGIN:VCALENDAR版本:2.0CALSCALE:公历方法:请求开始:事件UID:<unique-id>@<site>.comDTSTAMP:20210605T073803ZDTSTART;TZID=美国/瓜亚基尔:20210614T030000DTEND;TZID=美国/瓜亚基尔:20210614T040000摘要:我的活动组织者;CN=Juan Perez":mailto:jperez@organizer.com参加者;PARTSTAT=接受;CN="简美国能源部EMAIL=jdoe@gmail.com:MAILTO:jdoe@gmailcomURL;VALUE=URI:https://<site>.com/event/5960492994476830083结束:事件结束:VCALENDAR

如需了解更多详情,请查看我的 gist.

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!

解决方案

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.

这篇关于如何获取 ics 日历邀请以自动添加到日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 09:27