当我添加“方法:请求"时到 iCalendar,Gmail 停止识别为事件 [英] When I add "METHOD: REQUEST" to iCalendar, Gmail stops recognizing as event

查看:18
本文介绍了当我添加“方法:请求"时到 iCalendar,Gmail 停止识别为事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 iCalendar 为 Gmail 用户安排活动.但是,如果/当事件发生变化时,我希望能够发送更新.我读到我必须使用 METHOD:REQUEST 才能允许更新.

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 allow updates.

但是,当我将 METHOD:REQUEST 添加到我的 ics 文件时,Gmail 不再将其识别为日历邀请.

However, when I add the METHOD:REQUEST to my ics file, Gmail stops recognizing it as a calendar invite.

这是工作示例没有方法:请求"

Here is the working example WITHOUT "METHOD:REQUEST"

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Cratic//Cratic Huddle//EN
NAME:Cratic Huddle
X-WR-CALNAME:Cratic Huddle
TIMEZONE-ID:Europe/Berlin
X-WR-TIMEZONE:Europe/Berlin
BEGIN:VEVENT
UID:60212c8395841f2cd057864f@cratic.ai
SEQUENCE:0
DTSTAMP:20210208T130601Z
DTSTART:20210219T133059Z
DTEND:20210219T140059Z
SUMMARY:Cratic Huddle
DESCRIPTION:This is the information
ORGANIZER;CN="Izzi":mailto:firstname.lastname@gmail.com
ATTENDEE;ROLE=REQ-PARTICIPANT:MAILTO:firstname.lastname@gmail.com
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT15M
DESCRIPTION:Cratic Huddle
END:VALARM
BEGIN:VALARM
ACTION:AUDIO
TRIGGER:-PT15M
ATTACH;VALUE=URI:Basso
END:VALARM
URL;VALUE=URI:cratic.ai
END:VEVENT
END:VCALENDAR

以上工作完美;Gmail 会弹出一个按钮,询问我是否愿意接受.

The above works perfectly; Gmail pops up with a button asking if I want to accept.

这是不工作的例子WITH方法:请求"

Here is the NOT working example WITH "METHOD:REQUEST"

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Cratic//Cratic Huddle//EN
METHOD:REQUEST
NAME:Cratic Huddle
X-WR-CALNAME:Cratic Huddle
TIMEZONE-ID:Europe/Berlin
X-WR-TIMEZONE:Europe/Berlin
BEGIN:VEVENT
UID:60212c8395841f2cd057864f@cratic.ai
SEQUENCE:0
DTSTAMP:20210208T125937Z
DTSTART:20210219T133059Z
DTEND:20210219T140059Z
SUMMARY:Cratic Huddle
DESCRIPTION:This is the information
ORGANIZER;CN="Izzi":mailto:firstname.lastname@gmail.com
ATTENDEE;ROLE=REQ-PARTICIPANT:MAILTO:firstname.lastname@gmail.com
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT15M
DESCRIPTION:Cratic Huddle
END:VALARM
BEGIN:VALARM
ACTION:AUDIO
TRIGGER:-PT15M
ATTACH;VALUE=URI:Basso
END:VALARM
URL;VALUE=URI:cratic.ai
END:VEVENT
END:VCALENDAR

这会在 google 中生成一封空白电子邮件,并附有 .ics 文件.它不会出现在日历或其他任何地方.

This generates a blank email in google, with the .ics file attached. It does not appear in the calendar or anywhere else.

这两个 iCalendar 文件在其他方面完全相同.但由于某种原因,添加 METHOD:REQUEST 会破坏 ics 文件/谷歌读取它的能力.

These two iCalendar files are identical in every other way. But for some reason adding the METHOD:REQUEST is killing the ics file / google's ability to read it.

为什么??

推荐答案

好的 - 在阅读了 RFC5546、Stackoverflow 和许多其他博客数小时后,我终于有了答案.

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

范围:

  1. 向 Gmail/Outlook/Privateemail(namecheap 的电子邮件客户端)发送日历邀请
  2. 电子邮件客户端会自动识别 .ics 文件并生成接受"模板
  3. 在客户日历中自动显示为暂定"的事件
  4. 发送自动移动客户端日历事件的事件修订

有两个基本原则对完成这项工作至关重要:

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

  1. .ics 文件的内容必须与 Gmail/Outlook 社区的 .ics 文件非常匹配,这包括参数和顺序参数.

  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.

.ics 文件附加到电子邮件传输的方式很奇怪但很关键:(a) .ics 文件必须转换为base64",以及 (b) 文件的标题需要给出类型:'text/calendar;method=REQUEST;name="file.ics"'

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 内容示例:

let iCal = 

`BEGIN:VCALENDAR
PRODID:-//Cratic//_Scheduler//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:${DTStart}
DTEND:${DTEnd}
DTSTAMP:${DTStamp}
ORGANIZER;CN=name:mailto:name@gmail.com
UID:${event._id}@url.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=name@outlook.com;X-NUM-GUESTS=0:mailto:name@outlook.com
CREATED:${DTStamp}
DESCRIPTION:${event.body}
LAST-MODIFIED:${DTStamp}
LOCATION:${location}
SEQUENCE:${sequence}
STATUS:CONFIRMED
SUMMARY:${event.title}
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR`

请注意:以上顺序很重要!并且文本周围不能有死角,即使前后多一个空格也会干扰电子邮件客户端.此外,这是一个可重复使用的动态 iCal 事件模板,只要我保留事件的记录._id,我就可以使用该 _id 将修订发送给我的所有客户.

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.

将 .ics 附加到电子邮件客户端:

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

// build the email
const 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();

请注意:附件类型对于 Outlook 识别事件至关重要.

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.

这篇关于当我添加“方法:请求"时到 iCalendar,Gmail 停止识别为事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆