【问题标题】:Icalendar ICS update not working in google calendarIcalendar ICS 更新在谷歌日历中不起作用
【发布时间】:2021-03-09 19:12:38
【问题描述】:

我对 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

【问题讨论】:

  • 你解决过这个问题吗?我有同样的问题..
  • 同样的问题也出现了。其中一个答案是否可以解决问题?
  • 谢谢!它真的帮助了我。我可以确认,在我的测试中,至少使用 METHOD:PUBLISH 总是会导致重复约会。使用 METHOD:REQUEST 我可以根据需要更新约会。我发现我必须使用 METHOD:PUBLISH 来设置初始约会并发送该约会的更新。我也有 UID 字段匹配 SEQUENCE 字段递增和 ORGANIZER, ATTENDEE 字段设置如上。

标签: google-calendar-api icalendar rfc2445 rfc5545


【解决方案1】:

提供的某些答案并不(完全)正确。

简而言之,您的 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:为了便于测试,每次还要更改电子邮件的摘要和主题

清理示例:

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

【讨论】:

    【解决方案2】:

    参见 RFC5546 Update an Event

    事件被移到不同的时间。 “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"
    

    【讨论】:

    • 那么问题不在于 ical 文件,而可能在于您发送的电子邮件,您可以分享代码/mime 类型吗?
    • 我发布了原始电子邮件...我希望这会有所帮助:-)
    • 您是使用相同的发件人和收件人地址,还是只是发帖前的编辑?
    • 是的,为了隐私,我不得不更改地址(那不是我自己的数据,我不想发布其他人的数据)。
    • 当然我理解隐私的必要性,但您能否确认电子邮件From: 地址和organiser 地址与To: 地址相同和不同,后者与@ 相同987654328@地址?
    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 2019-01-21
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      • 2016-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-12
      相关资源
      最近更新 更多