Search code examples
c#icalendardday

How to generate the Organizer field with DDay.iCal?


I am using the C# library DDay.iCal and trying to produce the ORGANIZER field as defined in IETF RFC 2445:

ORGANIZER;CN=John Smith:MAILTO:[email protected]

A simple question: how can I do this? I have already tried several alternatives with no success: there is always something wrong with the result.


Solution

  • Answering this myself. This was pretty obvious after studying RFC 2445 (or 5545) more closely:

    iCalendar iCal = new iCalendar();
    Event ev = iCal.Create<Event>();
    
    ev.Organizer = new Organizer("MAILTO:[email protected]");
    ev.Organizer.CommonName = "John Smith";
    

    Ok, the result is not exactly the same:

    ORGANIZER;CN="John Smith":MAILTO:[email protected]
    

    However, MS Outlook accepts this format and this is what I was looking after.