【问题标题】:Incorrect timezone of EWS invitation on updatesEWS 更新邀请的时区不正确
【发布时间】: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


    【解决方案1】:

    当您的 ExchangeService 对象被实例化为时,尝试在 Appointment 对象上设置 StartTimeZone 和 EndTimeZone 属性:

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
    

    StartTimeZone 和 EndTimeZone 属性的行为因您运行的 Microsoft Exchange Server 版本而异。查看更多详情:Time zones in the EWS Managed API

    【讨论】:

    • 我也尝试设置现有约会的 StartTimeZone 和 EndTimeZone 但没有运气。 existingAppointment.StartTimeZone = TimeZoneInfo.FindSystemTimeZoneById("东部标准时间"); existingAppointment.EndTimeZone = TimeZoneInfo.FindSystemTimeZoneById("东部标准时间");
    • 您是否也更改了服务实例new ExchangeService(ExchangeVersion.Exchange2010_SP1);
    • 是的。仍然是相同的 UTC 时区。
    • 现有的预约时区是多少? Appointment.Bind(service, new ItemId(itemId)).StartTimeZone;
    • Appointment.Bind(service, new ItemId(itemId)).StartTimeZone 为空。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    • 1970-01-01
    • 2015-06-16
    • 2018-06-07
    相关资源
    最近更新 更多