문제

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);
}
도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top