我们的要求之一是创建iCalendar文件(.ics),并将每个文件作为附件发送给电子邮件。我们正在使用DDay.Ical.dll创建ics文件,如下所示:
// 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");
完整的过程是:
现在,假设由于任何原因取消了约会,则User1必须创建一个ics文件并将其发送给User2,以便User2可以从本地前景中取消其事件。
如何创建这样的ics文件?
文件的创建方式与原始ics文件的创建方式相同。事件状态将有所不同。 UID将标识事件,序列号将指示更新的优先级,然后将记录事件详细信息(更改或取消)
如果要在发出邀请后更改/取消事件,则需要通过其UID标识事件/约会,并分配比原始ics事件更大的SEQUENCE号。
UID(唯一标识符):http://tools.ietf.org/html/rfc5545#page-117
序列:http://tools.ietf.org/html/rfc5545#page-138
并设置事件状态
/ "CANCELLED" ;Indicates event was cancelled.
状态:http://tools.ietf.org/html/rfc5545#page-92
哦-和方法如果您需要发送取消事件,则UID应该与原始事件相同,并且组件属性应设置为取消Ex。方法:取消状态:已取消
当然,只有当接收者随后真正单击以将事件加载/订阅为第一次时,该事件才会“取消”该事件。对于已“订阅”了远程ic的应用程序-当它们下次进行“更新”时,应检查更新是否已处理并覆盖原始事件。
使用任何文本文件编辑器(例如Visual Studio Code)在ics文件中编辑所有事件,然后再次导入修改后的日历: