13

我对 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 电子邮件与 Sender 电子邮件相同,ATTENDEE 电子邮件与 Receiver 电子邮件相同。

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

4

3 回答 3

12

提供的一些答案不是(完全)正确的。

简而言之,您的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不需要与(旁注:但是,在ORGANIZERGoogle 日历中无法更新ORGANIZER
  • ORGANIZER不需要被列为ATTENDEE
  • 电子邮件recipient必须是ATTENDEE
  • 另外(如上所述),ATTENDEE需要额外的参数,而不仅仅是:mailto
  • STATUS不需要提供。编辑:在向谷歌日历/chrome/mac发送邀请时就是这种情况,但在其他组合中,邀请似乎没有得到正确的预览
  • 文档中包含多行的参数应在下一行缩进一个空格
  • 在 Google 日历生成的 iCalender 对象中,您可能会注意到太长的行在文档中被分成几行,但这不是必需的(例如,您可以提供一个很长的字符串的描述,只要确保它只需要一行将其剪切成每行缩进一个空格的行)
  • 额外提示:UID在原始邀请和更新中使用相同(这实际上不是必需的,但确保您的历史测试结果不受影响......)
  • 额外提示 2:为了更容易测试,每次还要更改电子邮件的摘要和主题

清理示例:

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可以更新的 - 我正在尝试制作一个不应该回复的日历发布应用程序。如果有人能弄清楚这一点,我将不胜感激。:-)

于 2018-03-31T06:54:00.980 回答
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

此外,您需要将发件人的电子邮件地址与组织者的电子邮件地址相匹配,并且与与会者相同,如下所示的内容已通过谷歌日历进行了验证。

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"
于 2013-02-05T20:03:23.213 回答
0

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

于 2013-03-08T16:55:50.393 回答