我正在使用 DDay 库来创建 iCal 事件,以便我网站的用户可以在他们的日历中添加一些内容。
我希望他们添加约会,而不是 Office 2010 中的会议请求(希望还有其他人)。当我使用库并将方法设置为 PUBLISH 时,它确实显示为约会,但报告在日历中找不到会议。然后,当我单击不需要响应时,该项目将被删除并且不会保留在他们的日历中。
如果我将方法更改为 REQUEST,它会显示为会议请求。这将是第二好的选择,但“to”字段为空白。如果这是我能做的最好的,我该如何设置“到”字段?我想我会让他们自己回应。
private static string CreateCalendarEvent(
string title, string body, DateTime startDate, double duration,
string location, string organizer, string eventId, bool allDayEvent)
{
// mandatory for outlook 2007
if(String.IsNullOrEmpty(organizer))
throw new Exception("Organizer provided was null");
var iCal = new iCalendar
{
Method = "PUBLISH",
Version = "2.0"
};
// "REQUEST" will update an existing event with the same UID (Unique ID) and a newer time stamp.
//if (updatePreviousEvent)
//{
// iCal.Method = "REQUEST";
//}
var evt = iCal.Create<Event>();
evt.Summary = title;
evt.Start = new iCalDateTime(startDate);
evt.Duration = TimeSpan.FromHours(duration);
evt.Description = body;
evt.Location = location;
evt.IsAllDay = allDayEvent;
evt.UID = String.IsNullOrEmpty(eventId) ? new Guid().ToString() : eventId;
evt.Organizer = new Organizer(organizer);
evt.Alarms.Add(new Alarm
{
Duration = new TimeSpan(0, 15, 0),
Trigger = new Trigger(new TimeSpan(0, 15, 0)),
Action = AlarmAction.Display,
Description = "Reminder"
});
return new iCalendarSerializer().SerializeToString(iCal);
}