我正在使用EWS 1.2发送约会。在创建新约会时,TimeZone会在通知邮件上正确显示,但在更新同一约会时,TimeZone会重置为UTC。更新约会时区更改为UTC
任何人都可以帮助我解决这个问题吗?
下面是示例代码复制的问题:当你绑定existingAppointment
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, 03, 27, 17, 00, 0);
newAppointment.End = newAppointment.Start.AddMinutes(30);
newAppointment.RequiredAttendees.Add("[email protected]");
//Attendees get notification mail for this appointment using (UTC-05:00) Eastern Time (US & Canada) timezone
//Here is the notification content received by attendees:
//When: Tuesday, March 27, 2012 5:00 PM-5:30 PM. (UTC-05:00) Eastern Time (US & Canada)
newAppointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);
// Pull existing appointment
string itemId = newAppointment.Id.ToString();
Appointment existingAppointment = Appointment.Bind(service, new ItemId(itemId));
//Attendees get notification mail for this appointment using UTC timezone
//Here is the notification content received by attendees:
//When: Tuesday, March 27, 2012 11:00 PM-11:30 PM. UTC
existingAppointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
我按照你的建议设置了AppointmentSchema.StartTimeZone,但EWS仍然以UTC时区发送通知邮件。 – 2012-04-02 13:21:42
@FirozAnsari了解。同样,当你在上面的代码中为'newAppointment'绑定它时会发生什么? [链接文章](http://msdn.microsoft.com/en-us/library/ee332363(v = exchg.140).aspx)似乎涵盖了针对Exchange 2010 EWS中的这个确切问题和功能的许多情况。除非您可以收集有关服务器属性的更多信息,否则我认为在定义明确的时区时与其联系是最合适的操作方式。 – MrGomez 2012-04-02 18:52:00
谢谢MrGomez。使用newAppointment,通知时区是正确的。我唯一的问题是更新现有的约会。我看了这篇文章,这篇文章解释了如何将开始日期和结束日期转换为特定的时区。我不知道如何在调用existingAppointment.Update时转换日期。再次感谢您的帮助。 – 2012-04-03 13:20:33