Icalendar ICS更新在谷歌日历中无法正常工作

17

我在使用Gmail/Google日历地址时遇到了ICS附件的一些问题。 当我需要编辑一个事件并通过电子邮件发送包含与原始事件相同UID的ICS文件进行更新时,GCalendar会添加第二个事件。我该如何解决这个问题?

以下是第一个ICS文件内容:

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20130425T090000
DTEND:20130425T100000
DTSTAMP:20130206T101100
ORGANIZER;CN=Test test:mailto:test@test.com
ATTENDEE:test@test.eu
UID:CALEVENT_TS090519840000000005
DESCRIPTION:test
SUMMARY:test
LOCATION:Test
SEQUENCE:1
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR

这是更新ICS文件的内容:

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20130425T100000
DTEND:20130425T110000
DTSTAMP:20130206T101100
ORGANIZER;CN=Test test:mailto:test@test.com
ATTENDEE:test@test.eu
UID:CALEVENT_TS090519840000000005
DESCRIPTION:test
SUMMARY:test
LOCATION:Test
SEQUENCE:2
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR

当我收到更新文件并点击“将此事件添加到日历”时,我会发现两个不同的事件。

这是原始邮件:

Delivered-To: test@test.eu
Received: by 10.216.231.19 with SMTP id k19csp190640weq;
        Sat, 9 Feb 2013 08:01:11 -0800 (PST)
X-Received: by 10.194.7.136 with SMTP id j8mr15530679wja.38.1360425671327;
        Sat, 09 Feb 2013 08:01:11 -0800 (PST)
Return-Path: <test@test.eu>
Received: from mxavas8.aruba.it (mxavas8.aruba.it. [62.149.157.18])
        by mx.google.com with SMTP id 45si59706250eeg.83.2013.02.09.08.01.11;
        Sat, 09 Feb 2013 08:01:11 -0800 (PST)
Received-SPF: neutral (google.com: 62.149.157.18 is neither permitted nor denied by best guess record for domain of test@test.eu) client-ip=62.149.157.18;
Authentication-Results: mx.google.com;
       spf=neutral (google.com: 62.149.157.18 is neither permitted nor denied by best guess record for domain of test@test.eu) smtp.mail=test@test.eu
Received: (qmail 4991 invoked by uid 89); 9 Feb 2013 16:01:10 -0000
Delivered-To: test.eu-test@test.eu
Received: (qmail 4424 invoked by uid 89); 9 Feb 2013 16:01:04 -0000
Received: from unknown (HELO mxcmd03.ad.aruba.it) (10.10.10.67)
  by mxavas8.ad.aruba.it with SMTP; 9 Feb 2013 16:01:04 -0000
Received: from smtpdg11.aruba.it ([62.149.158.229])
    by mxcmd03.ad.aruba.it with bizsmtp
    id yFwi1k01A4xF4Fy01G14N7; Sat, 09 Feb 2013 17:01:04 +0100
Received: from localhost ([79.54.181.227])
    by smtpcmd04.ad.aruba.it with bizsmtp
    id yG141k0074umbYX01G140P; Sat, 09 Feb 2013 17:01:04 +0100
Date: Sat, 9 Feb 2013 17:01:04 +0100
Return-Path: test@test.eu
To: test@test.eu
From: Event notification <test@test.eu>
Reply-To: Event notification <test@test.eu>
Subject: New Event
Message-ID: <238497c6d05cffae45716486e74a8009@localhost>
X-Priority: 3
X-Mailer: PHPMailer 5.2.2 (http://code.google.com/a/apache-extras.org/p/phpmailer/)
MIME-Version: 1.0
Content-Type: multipart/mixed;
    boundary="b1_238497c6d05cffae45716486e74a8009"
X-Spam-Rating: mxavas8.ad.aruba.it 1.6.2 0/1000/N

--b1_238497c6d05cffae45716486e74a8009
Content-Type: multipart/alternative;
    boundary="b2_238497c6d05cffae45716486e74a8009"

--b2_238497c6d05cffae45716486e74a8009
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

test

        DateTimeRoom
        02/05/201309.00 - 10.15ROOM1


--b2_238497c6d05cffae45716486e74a8009
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;">
<style type="text/css">
<!--
    td{ background-color: #eee; }
-->
</style>
</head>
<body style="font-family: Arial, Helvetica, sans-serif; color: #333;">
<p style="text-align:center;"><img src="images/logo2.png" alt="Logo" /></p>
<hr style="border: 1px solid #ccc; width: 80%;" />
<div style=" width: 80%; margin: 10px auto;">
    <h4></h4>
    <h3>test</h3>
    <table style="width: 400px; table-layout: fixed; border: 1px solid #ccc;">
        <tr><th>Date</th><th>Time</th><th>Room</th></tr>
        <tr><td>02/05/2013</td><td>09.00 - 10.15</td><td>ROOM 1</td></tr>
    </table>
</div>
</body>
</html>



--b2_238497c6d05cffae45716486e74a8009--

--b1_238497c6d05cffae45716486e74a8009
Content-Type: text/calendar; name="event.ics"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="event.ics"

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:tsCalendar
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20130502T090000
DTEND:20130502T101500
DTSTAMP:20130209T170100
ORGANIZER:mailto:test@test.eu
ATTENDEE:mailto:test@test.eu
UID:CALEVENT_TS090519840000000013
DESCRIPTION:test
SUMMARY:test
LOCATION:ROOM1 (floor: prova)
SEQUENCE:1
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR


--b1_238497c6d05cffae45716486e74a8009--

以下是使用与发件人电子邮件相同的ORGANIZER电子邮件和接收者电子邮件相同的ATTENDEE电子邮件进行的其他测试。

创建http://tny.cz/6396ba62 更新http://tny.cz/08ac81c0


3
你有解决这个问题吗?我也遇到了同样的问题。 - Peter
同样的问题也出现了。有没有一个答案解决了这个问题? - Adriaan
谢谢!这真的帮了我很多。在我的测试中,至少使用METHOD:PUBLISH会导致重复的约会。使用METHOD:REQUEST,我可以按预期更新约会。我发现我必须同时使用METHOD:PUBLISH来设置初始约会和发送该约会的更新。我还发现UID字段匹配SEQUENCE字段递增,并将ORGANIZER、ATTENDEE字段设置为上述内容。 - darkhipo
3个回答

14
一些提供的答案不是(完全)正确的。
简而言之,你的 ATTENDEE 属性需要更多的参数,以确保 Google 日历将其视为更新:
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
TRUE;CN=Recipient Name;X-NUM-GUESTS=0:mailto:recipient@gmail.com

我遇到了同样的问题,为了找到答案,我:

  1. 使用 Google 日历本身和更新后的邀请向自己发送邀请
  2. 比较两个 .ics 文件
  3. 运行许多不同的自动生成的这两个 .ics 文件的变体,以找出哪些参数是真正必要的

这是我的发现:

  • 将 SEQUENCE 从 0 增加到 1(或更高,如果您想更新更新)
  • METHOD 必须是 REQUEST (*1)
  • 电子邮件 sender 不需要与 ORGANIZER 相同(旁注:在 Google 日历中无法更新 ORGANIZER
  • ORGANIZER 不需要列为 ATTENDEE
  • 电子邮件 recipient 必须是一个 ATTENDEE
  • 此外(如上所述),ATTENDEE 需要其他参数,而不仅仅是 :mailto
  • STATUS 不需要提供。编辑:当向 Google 日历/Chrome/Mac 发送邀请时,情况是如此,但在其他组合中,邀请似乎没有得到适当的预览
  • 在文档中占据多行的参数应该在下一行缩进一个空格
  • 在由 Google 日历生成的 iCalender 对象中,您可能会注意到过长的行被分成几行进入文档,但这不是必需的(例如,您可以提供一个非常长的字符串描述,只需确保它仅占用一行 或者 将其划分为每行缩进一个空格的行)
  • 额外提示:在原始邀请和更新中使用相同的 UID(实际上并不需要,但可以确保您的历史测试结果不受影响...)
  • 额外提示2:为了更轻松地进行测试,还要每次更改您的电子邮件的 SUMMARY 和主题

清理后的示例:

BEGIN:VCALENDAR
PRODID:-//YourCompany/AppName//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20180331T150000
DTEND:20180331T160000
DTSTAMP:20180331T150000 // make sure to populate this dynamically
ORGANIZER;CN=organizer@gmail.com:mailto:organizer@gmail.com
UID:BESTIDEVER123
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
TRUE;CN=Recipient Name;X-NUM-GUESTS=0:mailto:recipient@gmail.com
CREATED:20180331T150000  // make sure to populate this dynamically
DESCRIPTION:Best event evah
LAST-MODIFIED:20180331T150000 // make sure to populate this dynamically
LOCATION:
SEQUENCE:0 // don't forget to increment this!!
SUMMARY:A Wonderful Event
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

(*1) 我唯一无法解决的问题是如何更新 METHOD:PUBLISH - 我正在尝试制作一个不需要回复的日历发布应用程序。如果有人能够解决这个问题,我将不胜感激。:-)


9
请参考RFC5546 更新事件

将事件更改为不同的时间。 "UID"属性(未更改)和 "SEQUENCE"(增加到1)属性的组合表示更新。

根据你提供的信息,你可能需要在你的ical文件中添加一个SEQUENCE属性,并且每次更新时都要增加它。 更新: 根据你提供的ical文件,你缺少组织者和参与者字段,使用下面的文件进行更新即可。
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:pyICSParser
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20130425T090000
DTEND:20130425T100000
DTSTAMP:20130206T101100
ORGANIZER:mailto:organiser@example.com
ATTENDEE:mailto:attendee@example.com
UID:CALEVENT_TS090519840000000005
DESCRIPTION:test
SUMMARY:test
LOCATION:Test
SEQUENCE:1
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR

您需要将发件人的电子邮件地址与组织者的电子邮件地址匹配,并对参与者进行相同的操作,类似于下面使用Google日历进行验证的内容。

eml_as_string:

Subject: New Event
Message-ID: <238497c6d05cffae45716486e74a8009@localhost>
X-Priority: 3
X-Mailer: PHPMailer 5.2.2 (http://code.google.com/a/apache-extras.org/p/phpmailer/)
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="b1_238497c6d05cffae45716486e74a8009"
X-Spam-Rating: mxavas8.ad.aruba.it 1.6.2 0/1000/N

--b1_238497c6d05cffae45716486e74a8009
Content-Type: multipart/alternative;
boundary="b2_238497c6d05cffae45716486e74a8009"

--b2_238497c6d05cffae45716486e74a8009
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

test

DateTimeRoom
02/05/201309.00 - 10.15ROOM1


--b2_238497c6d05cffae45716486e74a8009
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;">
<style type="text/css">
<!--
td{ background-color: #eee; }
-->
</style>
</head>
<body style="font-family: Arial, Helvetica, sans-serif; color: #333;">
<p style="text-align:center;"><img src="images/logo2.png" alt="Logo" /></p>
<hr style="border: 1px solid #ccc; width: 80%;" />
<div style=" width: 80%; margin: 10px auto;">
<h4></h4>
<h3>test</h3>
<table style="width: 400px; table-layout: fixed; border: 1px solid #ccc;">
    <tr><th>Date</th><th>Time</th><th>Room</th></tr>
    <tr><td>02/05/2013</td><td>09.00 - 10.15</td><td>ROOM 1</td></tr>
</table>
</div>
</body>
</html>



--b2_238497c6d05cffae45716486e74a8009--

--b1_238497c6d05cffae45716486e74a8009
Content-Type: text/calendar; name="event.ics"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="event.ics"

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:tsCalendar
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20130502T090000
DTEND:20130502T101000
DTSTAMP:20130209T170100
ORGANIZER:mailto:test@test.eu
ATTENDEE:mailto:test@test.eu
UID:CALEVENT_TS090519840000000013
DESCRIPTION:test
SUMMARY:test
LOCATION:ROOM1 (floor: prova)
SEQUENCE:1
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR


--b1_238497c6d05cffae45716486e74a8009--

以下脚本应用于此处:

# -*- coding:utf-8 -*-
import smtplib
def sendInvite(fro,to,emlasstring):
    mailServer = smtplib.SMTP('smtp.gmail.com', 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(login, password)
    mailServer.sendmail(fro, to, emlasstring)
    mailServer.close()

newUID = "UID:newCALEVENT_TS090519840000000016"
#needed to change UID as once an event was sent its UID is locked and a few attempts were needed to make the script work
eml = open("SO14712929_1.eml",'r').read()
emlhead = "To: "+attendee_eml+CRLF
emlhead += "From:"+fro+CRLF
emlhead += "Reply-To: "+fro+CRLF
eml = emlhead+eml
eml = eml.replace("ORGANIZER:mailto:test@test.eu","ORGANIZER:mailto:"+fro_eml)
eml = eml.replace("ATTENDEE:mailto:test@test.eu","ATTENDEE:mailto:"+attendee_eml)
eml = eml.replace("UID:CALEVENT_TS090519840000000013",newUID)
sendInvite(fro,attendees,eml)
print "invite sent"

eml = open("SO14712929_2.eml",'r').read()
emlhead = "To: "+attendee_eml+CRLF
emlhead += "From:"+fro+CRLF
emlhead += "Reply-To: "+fro+CRLF
eml = emlhead+eml
eml = eml.replace("ORGANIZER:mailto:test@test.eu","ORGANIZER:mailto:"+fro_eml)
eml = eml.replace("ATTENDEE:mailto:test@test.eu","ATTENDEE:mailto:"+attendee_eml)
eml = eml.replace("UID:CALEVENT_TS090519840000000013",newUID)
sendInvite(fro,attendees,eml)
print "updated invite sent"

如果问题不在于ical文件,而是可能与您发送的电子邮件有关,您可以分享代码/ MIME类型吗? - Auberon Vacher
我已发布了原始电子邮件消息...希望这能帮到你 :-) - Tobia
1
我理解隐私的需要,但您能否确认电子邮件中“发件人”地址和“组织者”地址是否相同且不同于“收件人”地址,而“收件人”地址与“参与者”地址相同? - Auberon Vacher
我已经更新了我的回答:根据您的电子邮件并进行上述更改:From 匹配 organizerTo 匹配 attendee,Google 日历会更新事件。 - Auberon Vacher
不,这就像是收到一个新事件。如果我点击“保存到您的日历”它会创建另一个事件...这可能与邮箱地址别名有关吗? - Tobia
显示剩余6条评论

0

尝试使用METHOD:PUBLISH而不是METHOD:REQUEST


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接