更新时EWS邀请的时区不正确 [英] Incorrect timezone of EWS invitation on updates

查看:85
本文介绍了更新时EWS邀请的时区不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在任何现有约会更新时指定EWS邀请的时区.这是我的代码:

I am trying to specify timezone of EWS invitations when any existing appointment get updated. Here is my code:

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在创建新约会(newAppointment.Save在上面的代码中)并将邀请发送给与会者时使用正确的时区(UTC-05:00).但是,当EWS更新任何现有约会并发送更新的邀请时,它将错误的时区用作UTC.

EWS use proper timezone (UTC-05:00) when it create new appointment (newAppointment.Save in above code) and send invitations to attendees. But when EWS updates any existing appointment and send updated invitations, it use incorrect timezone as UTC.

请注意,我在创建交换服务对象实例时指定了东部标准时间"时区.

Note that I am specifying "Eastern Standard Time" timezone while creating instance of exchange service object.

推荐答案

在将ExchangeService对象实例化为以下对象时,还尝试在约会对象上设置StartTimeZone和EndTimeZone属性:

Try to set StartTimeZone and EndTimeZone properties also on the Appointment object when your ExchangeService object is instantiated as:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

StartTimeZone和EndTimeZone属性的行为取决于您所运行的Microsoft Exchange Server的版本.查看更多详细信息:EWS托管API中的时区.

The behavior of the StartTimeZone and EndTimeZone properties varies based on the version of Microsoft Exchange Server that you are running. See more details: Time zones in the EWS Managed API.

这篇关于更新时EWS邀请的时区不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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