我正在使用 EWS 1.2 发送约会。在创建新约会时,时区在通知邮件上正确显示,但在更新同一约会时,时区重置为 UTC。
谁能帮我解决这个问题?
这是复制问题的示例代码:
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("tin.tin@acme.com");
//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
并在绑定(bind) existingAppointment
时将其绑定(bind)为属性对象的一部分,如 illustrated here :
// Get an existing calendar item, requesting the Id, Start, and
// StartTimeZone properties.
PropertySet props = new PropertySet(
AppointmentSchema.Id,
AppointmentSchema.Start,
AppointmentSchema.StartTimeZone);
Appointment appt = Appointment.Bind(service, new ItemId("AQMkA="), props);
似乎默认绑定(bind)时区是 UTC。
关于sharepoint-2010 - 更新约会时时区更改为 UTC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9910129/