错误EWS指定的时区不是.net

时间:2017-12-11 19:06:27

标签: c# .net exchangewebservices

我正在使用EWS向我公司的帐户发送约会,这些帐户是在c#.net MVC 3上开发的。

代码

var service = new ExchangeService(ExchangeVersion.Exchange2013,TimeZoneInfo.Local);
            service.Credentials = new WebCredentials("myuser", "mypassowrd", "mycompany");
            service.TraceEnabled = true;
            service.TraceFlags = TraceFlags.All;
            service.Url = new Uri(uriString: "myexchangeserver" );
            TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Pacific SA Standard Time");

            Appointment appointment = new Appointment(service);

            appointment.Subject = "TestMeeting";
            appointment.Body = "The purpose of this meeting is to discuss status.";
            appointment.Start = new DateTime(2017, 12, 12, 9, 0, 0);
            appointment.End = appointment.Start.AddHours(2);
            appointment.Location = "Conf Room";
            appointment.RequiredAttendees.Add("myemail@mycompany.cl");
            appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);

我的问题如下,当我执行代码直到最后一行时,下一个异常返回:

{"The specified time zone isn't valid."}

我无法找到任何解决方案,如果您需要更多信息,请在评论中注明,非常感谢并抱歉我的英语不好:c

1 个答案:

答案 0 :(得分:0)

此错误已在github上的EWS API中报告为问题。

然而,它看起来更像是.NET的TimeZoneInfo解析逻辑中的一个问题。更新您的 .net 版本可能是解决方案。

以下是包含其他可能解决方案的article