在更新约会时,TimeZone更改为UTC [英] TimeZone change to UTC while updating the Appointment

查看:128
本文介绍了在更新约会时,TimeZone更改为UTC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用EWS 1.2发送约会.创建新的约会时,TimeZone会正确显示在通知邮件上,但是更新同一约会时,TimeZone会重置为UTC.

I am using EWS 1.2 to send appointments. On creating new Appointments, TimeZone is showing properly on notification mail, but on updating the same appointment, it's TimeZone reset to UTC.

有人可以帮助我解决此问题吗?

Could anyone help me to fix this issue?

以下是用于复制问题的示例代码:

Here is sample code to replicate the issue:

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);

推荐答案

在绑定existingAppointment时,您需要设置AppointmentSchema.StartTimeZone并将其绑定为属性对象的一部分,如

You'll want to set AppointmentSchema.StartTimeZone and bind it as part of the properties object when you bind existingAppointment, as 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);

似乎默认的绑定时区是UTC.

It seems the default bound time zone is UTC.

这篇关于在更新约会时,TimeZone更改为UTC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆