0
        ItemId id=null;
        string s = "";
        const string dts = " dd.MM.yyyy HH:mm ";
        if(true) {
            TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
            ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2010, tz);
            ews.AutodiscoverUrl("Alexander@contoso.com");
            Appointment app = new Appointment(ews);
            app.IsAllDayEvent = true;
            app.StartTimeZone = tz;
            app.EndTimeZone = tz;
            app.Start = DateTime.Now;
            app.End = DateTime.Now;
            app.Save(SendInvitationsMode.SendToNone);
            id = app.Id;
            Console.WriteLine(app.Start.ToString(dts));
        }
        if(true) {
            TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
            ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2010, tz);
            ews.AutodiscoverUrl("Alexander@contoso.com");
            Appointment app = Appointment.Bind(ews,id);
            Console.WriteLine(app.Start.ToString(dts));

            app.IsAllDayEvent = true;
            app.StartTimeZone = tz;
            app.EndTimeZone = tz;
            app.Start = DateTime.Now;
            app.End = DateTime.Now;
            app.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);
            Console.WriteLine(app.Start.ToString(dts));
        }
        if (true)
        {
            TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
            ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2010, tz);
            ews.AutodiscoverUrl("Alexander@contoso.com");
            Appointment app = Appointment.Bind(ews, id);
            Console.WriteLine(app.Start.ToString(dts));
        }

The console output is:

 05.05.2014 18:17 
 05.05.2014 00:00 
 05.05.2014 18:17 
 05.05.2014 02:00

So creating a new All-day event works like a charm (which is better than what I had this morning).

But why is the last line 02:00, and how do I have to rewrite my program to have 00:00 CEST stored as the all-day appointment start date?

Alexander
  • 19,906
  • 19
  • 75
  • 162
  • Downvote without comment... nice! – Alexander May 06 '14 at 07:09
  • Did you try not setting the StartTimeZone and EndTimeZone properties on the Appointment object? As far as I remember you should not set those properties if you specify the timezone when creating the ExchangeService object. – Jakob Christensen May 08 '14 at 07:46
  • I tried, but it didn't change anything at all. The combination `Save() -> IsAllDayEvent=true -> Update()` seems to be poisonous. – Alexander May 08 '14 at 09:53

1 Answers1

0

I am not a developer, but looking into this issue for our (Java) developers. It looks like you have to get all the timezones from the original appointment or you will run into this issue... of the references/ other stack overflow questions below, number 5 got it and that was the last one that I found :(

  1. You are at the same stage as the person asking this one
  2. One step closer, the actual time is correct, but the meeting displays the wrong time zone.
  3. This similar question without answer
  4. Answered for these versions but I can't see what it means: Exchange Server 2007 Service Pack 1 (SP1) / Exchange Server 2010
  5. This one actually got it to work right. referencing this answer on the Microsoft fora

If this helps someone, maybe the others can also finally be closed :)

Community
  • 1
  • 1
  • Microsoft told me that setting `IsAllDayEvent=true` on an existing appointment does not work correctly in Echange 2010 and Exchange 2010 SP 1. Exchange 2010 SP2 fixes the problem (but only if you connect with ExchangeVersion.Exchange2010_SP2...). – Alexander Jan 29 '15 at 13:43