Icalendar ICS update not working in google calendar

后端 未结 3 664
孤街浪徒
孤街浪徒 2021-01-11 17:24

I have some trouble with the ICS attachment to Gmail/Google calendar addresses. When I have to edit an event I send an update by mail with an ICS file with the same UID of t

3条回答
  •  轮回少年
    2021-01-11 17:51

    see RFC5546 Update an Event

    The event is moved to a different time. The combination of the "UID" property (unchanged) and the "SEQUENCE" (bumped to 1) properties indicate the update.

    in your case given what you shared you probably need to add a SEQUENCE property in your ical file and increment it for every update you make.

    Update: given the ical file you added, you are missing the organiser and attendee fields with below file the update work

    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
    

    Also you need to match the email address of the sender with the one from organiser and same about the attendee, something like below has been validated with google calendar.

    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
    
    
    
    
    
    
    
    

    Logo


    test

    DateTimeRoom
    02/05/201309.00 - 10.15ROOM 1
    --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--

    on which below script was applied:

    # -*- 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"
    

提交回复
热议问题