【发布时间】:2012-02-29 05:24:27
【问题描述】:
我正在尝试在任何现有约会得到更新时指定 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。
请注意,我在创建交换服务对象实例时指定了“东部标准时间”时区。
【问题讨论】:
标签: sharepoint-2010 timezone exchange-server