How to cancel an calendar event using ics files?
Asked Answered
S

4

31

One of our requirements is to create iCalendar files (.ics) and send them each in emails as an attachment. We are using DDay.Ical.dll to create ics files as under:

// Create a new iCalendar
iCalendar iCal = new iCalendar();

// Create the event, and add it to the iCalendar
Event evt = iCal.Create<Event>();

// Set information about the event
evt.Start = new iCalDateTime(SomeStartTime);
evt.End = new iCalDateTime(SomeEndTime);
evt.Location = "At so and so place";
evt.Description = "Some Description";
evt.Summary = "About Some Subject";
iCal.Method = "PUBLISH";

// Serialize (save) the iCalendar
iCalendarSerializer serializer = new iCalendarSerializer();
serializer.Serialize(iCal, @"iCalendar.ics");

Complete process is:

  1. User1 create an iCal file for specific date and time and send it to User2.
  2. User2 will open the ics file and accept the invitation. An appointment item will be created in User2's LOCAL outlook.

Now, Suppose, because of any reason if appointment is cancelled, then User1 HAS to create an ics file and send it to User2, so that User2 can cancel his event from the local outlook.

How to create such ics file?

Sculpt answered 11/5, 2012 at 12:54 Comment(0)
I
37

File gets created in the same way as the original ics file. The event status will be different. UID will identify the event and sequence number will indicate priority of update, and then the event details will be noted (changes or cancellations)

If you want to change/cancel an event after sending out an invitation, you need to identify the event/appointment by its UID, and allocate a bigger SEQUENCE number than the original ics event.

UID (unique identifier) : https://www.rfc-editor.org/rfc/rfc5545#page-117

Sequence: https://www.rfc-editor.org/rfc/rfc5545#page-138

and set the event status

             / "CANCELLED"    ;Indicates event was cancelled.

Status: https://www.rfc-editor.org/rfc/rfc5545#page-92

oh - and method If you need to send in a cancellation for an event the UID should be same as the original event and the component properties should be set to cancel Ex. METHOD:CANCEL STATUS:CANCELLED

Of course this will only 'cancel' the event if the recipient then actually clicks to load/subscribe it into the same calendar app as the first time. For applications that have 'subscribed' the the remote ics - when they next do an 'update' check the update should be processed and overwrite the original event.

Interstellar answered 12/5, 2012 at 7:3 Comment(1)
I was testing this with my outlook client, surprisingly when I cancel a meeting from outlook and read the ics file on the receiver end, I do not find STATUS flag there, let alone cancelled. Also, the VEVENT is set to CANCEL, but I am not sure if that is a good enough indication of if meeting was cancelled ? Can you please tell me what other things I can check on the receiver side to know if this is a cancelled meeting? I need it for some workflow!Marlomarlon
B
16

Old thread, but just wanted to give my input.

Also had the problem with outlook showing "not supported format" on a cancel ics. Tried to change METHOD to REQUEST, sort of solved the problem in Outlook, but Gmail and others was not handling it well, looked like an invite, with yes/no/maybe buttons.

After much (MUCH) looking around for solve the problem, I finally realized that the problem was not within the ics file, but how the file was attached to the email. I added it with method:REQUEST. After changing that to method:CANCEL it works well in all clients.

contype = new System.Net.Mime.ContentType("text/calendar");
//contype.Parameters.Add("method", "REQUEST");
contype.Parameters.Add("method", "CANCEL");
contype.Parameters.Add("charSet", "utf-8");
contype.Parameters.Add("name", "invite.ics");
Bijouterie answered 22/3, 2021 at 10:2 Comment(1)
Thank you. This helped me properly solve the same issue you faced just now. I found the relevant part of the iCalendar spec here: tools.ietf.org/html/rfc5545#section-3.7.2 Looks like only Outlook actually validates that.Rudd
R
7

Edit all the events in the ics file using any text file editor (eg. Visual Studio Code) and import modified the calenar again:

enter image description here

Ravel answered 3/3, 2020 at 10:45 Comment(3)
i did the same as your image, but it all the time add this appointment in my calendar, can you explain it more?Handful
Nothing more to add really - I just updated the fields and imported calendar again - worked for me (I did it for the google calendar).Ravel
ok , i try the same this outlook calendar , and it added the event rather then canceling it, ok i try again. thanks for replyHandful
H
5

I had the issue when i sent mail containing ics file for delete event but in outlook it show me not supported format then i figured out somewhere on net and i found that i just need to change METHOD: CANCEL to METHOD: REQUEST

enter image description here

when i import this in outlook enter image description here

Handful answered 2/6, 2020 at 8:13 Comment(3)
Hey, just wanted to say thanks for documenting this. The combination of METHOD:REQUEST and STATUS:CANCELLED (along with incrementing the SEQUENCE) is what I needed to get cancellation working in the Calendar app on Mac!Satterlee
Thanks a ton! You save so many hours in my lifeSorehead
This works well for mac calendar app and outlook but not for google calendar. It still shows Yes/No/Maybe options for the event. I am using rails icalendar gem and facing same issue for the cancel event. Let me know if someone had any solution.Eno

© 2022 - 2024 — McMap. All rights reserved.