我正在使用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