更新时EWS邀请的时区不正确

时间:2012-02-28 15:07:48

标签: sharepoint-2010 timezone exchange-server

我正在尝试在任何现有约会更新时指定EWS邀请的时区。 这是我的代码:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
service.Credentials = new WebCredentials("ews_calendar", PASSWORD, "acme");
service.Url = new Uri("https://acme.com/EWS/Exchange.asmx");

Appointment newAppointment = new Appointment(service);
newAppointment.Subject = "Test Subject";
newAppointment.Body = "Test Body";
newAppointment.Start = new DateTime(2012, 02, 28, 17, 00, 0);
newAppointment.End = newAppointment.Start.AddMinutes(30);
newAppointment.RequiredAttendees.Add("tin.tin@acme.com");

//When: Tuesday, February 28, 2012 5:00 PM-5:30 PM. (UTC-05:00) Eastern Time (US & Canada)
newAppointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);

string itemId = newAppointment.Id.ToString();

Appointment existingAppointment = Appointment.Bind(service, new ItemId(itemId));
existingAppointment.Start = new DateTime(2012, 02, 28, 18, 00, 0);
existingAppointment.End = existingAppointment.Start.AddMinutes(30);

//When: Tuesday, February 28, 2012 11:00 PM-11:30 PM. UTC
existingAppointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);

EWS在创建新约会时使用适当的时区(UTC-05:00)(上述代码中的newAppointment.Save)并向与会者发送邀请。但是,当EWS更新任何现有约会并发送更新的邀请时,它会使用不正确的时区作为UTC。

请注意,我在创建交换服务对象的实例时指定了“东部标准时间”时区。

1 个答案:

答案 0 :(得分:0)

当您将ExchangeService对象实例化为:

时,尝试在Appointment对象上设置StartTimeZone和EndTimeZone属性
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

StartTimeZone和EndTimeZone属性的行为因您运行的Microsoft Exchange Server版本而异。查看更多详情:Time zones in the EWS Managed API