How to set time zones with DDay.iCal

4.1k views Asked by At

I am using DDay.iCal to send an event that should be received by Outlook 2013. This is the part of the code where I am setting the dates:

evt.Created = new iCalDateTime(DateTime.Now);
evt.LastModified = new iCalDateTime(DateTime.Now);
evt.UID = Guid.NewGuid().ToString();
evt.DTStamp = new iCalDateTime(DateTime.Now);
evt.Duration = TimeSpan.FromHours(4);
evt.DTEnd = new iCalDateTime(DateTime.Now.AddHours(4));

When I receive the corresponding meeting request in Outlook 2013, I am getting this:

The organizer created this meeting in the following time zone: (UTC) Monrovia, Reykjavik

What time zones can I set? I have tried a few, such as:

evt.Created = new iCalDateTime(DateTime.Now, "GMT");
evt.LastModified = new iCalDateTime(DateTime.Now, "GMT");
evt.UID = Guid.NewGuid().ToString();
evt.DTStamp = new iCalDateTime(DateTime.Now, "GMT");
evt.Duration = TimeSpan.FromHours(4);
evt.DTEnd = new iCalDateTime(DateTime.Now.AddHours(4), "GMT");

...and...

evt.Created = new iCalDateTime(DateTime.Now, "Eastern Standard Time");
evt.LastModified = new iCalDateTime(DateTime.Now, "Eastern Standard Time");
evt.UID = Guid.NewGuid().ToString();
evt.DTStamp = new iCalDateTime(DateTime.Now, "Eastern Standard Time");
evt.Duration = TimeSpan.FromHours(4);
evt.DTEnd = new iCalDateTime(DateTime.Now.AddHours(4), "Eastern Standard Time");

When I do this, instead of a meeting request, in Outlook 2013 I get an email with an attachment called not supported calendar message.ics.

How can I set the time zone correctly (or at least some default setting, so that Outlook won't show the message mentioned earlier)?

Edit: below is the content of the .ics file:

BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
PRODID:-//ddaysoftware.com//NONSGML DDay.iCal 1.0//EN
BEGIN:VEVENT
CREATED:20140602T094431
DESCRIPTION:Test test
DTEND:20140602T134431
DTSTAMP:20140602T074431Z
DTSTART:20140602T094431
LAST-MODIFIED:20140602T094431
ORGANIZER:mailto:[email protected]
PRIORITY:3
SEQUENCE:1
SUMMARY:Test 2
UID:df6b9f7c-2986-49f1-8b46-78d50193904c
BEGIN:VALARM
ACTION:Display
DESCRIPTION:Reminder
DURATION:PT15M
TRIGGER:PT15M
END:VALARM
END:VEVENT
END:VCALENDAR
1

There are 1 answers

0
Gigi On BEST ANSWER

This answer solved the problem for me. The solution was to use:

iCal.AddLocalTimeZone();

It is also possible to set arbitrary time zones based on system timezones... see that answer for details.