Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

outlook - How to cancel an calendar event using ics files?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...