How do I create an Outlook “appointment” with DDay.iCal?

依然范特西╮ 提交于 2019-12-05 20:53:57

问题


I'm using the DDay library to create an iCal event, so that users of my site can add something to their calendar.

I want them to add an appointment as opposed to a meeting request in Office 2010 (and hopefully others too). When I use the library and set the method to PUBLISH, it does appear as an appointment, but it reports that the meeting cannot be found in the calendar. Then when I click no response required, the item gets deleted and doesn't stay in their calendar.

If I change the method to REQUEST, it shows up as a meeting request. This would an okay second best option, but the 'to' field is blank. If that's the best I can do, how can I set the 'to' field? I guess I would have them respond to themselves.

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);
}

回答1:


When I set the organizer to an email address, as opposed to a test string, it worked fine. I had written all of this up, so I thought I'd share it in case anyone else had the same problem




回答2:


My app stopped working when the exchange server was upgraded to Outlook 2010 from 2003. Before the upgrade PUBLISH worked fine but now I had to change to REQUEST

Thanks for the article



来源:https://stackoverflow.com/questions/12112323/how-do-i-create-an-outlook-appointment-with-dday-ical

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!