• EWS(Exchange Web services)时区问题解决


    最近有项目用到EWS API的发起会议,时区一起无法找到正确解决办法,如果时区不对,那么会议时间和UTC时间会冲突的。显示如下错误:

    image

    经过MSDN资料查找,原来可以设置时区的。

    TimeZoneInfo.FindSystemTimeZoneById("China Standard Time")表示北京时间
    TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");表示美国中部时间
    依次类推
    

    代码如下:

     ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1, TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"));
                 service.Credentials = new NetworkCredential("XXXX", "XXXX", "XXX.com");
                    service.Url = new Uri("https://XXX.XXX.com/EWS/Exchange.asmx");
                
                //实例化一个Appointment
                Appointment appointment = new Appointment(service);
                //约会主题
                appointment.Subject = "测试UTC,设置了北京时间?";
                //约会内容
                appointment.Body = "测试,设置了北京时间";
                //约会开始时间2010-6-1 12:30:00
                appointment.Start = new DateTime(2012, 11, 29, 08, 30, 0);
                //约会结束
                appointment.End = appointment.Start.AddDays(5);
                //约会的位置
                appointment.Location="216会议室";
                //添加与会者
                
                appointment.RequiredAttendees.Add("XXX@XXXX.com");
               
                // 从2010-6-1 12:30:00开始每周举行一次
                //appointment.Recurrence = new Recurrence.WeeklyPattern(appointment.Start,1,DayOfWeek.Saturday);
                //可以设置发送通知的方式,如:
                //Appointment.Save(SendInvitationsMode.SendOnlyToAll)
                appointment.Save();
                MessageBox.Show("ok");

    正确效果图如下:

    image

  • 相关阅读:
    HDU 3709 Balanced Number
    HDU 3652 B-number
    HDU 3555 Bomb
    全局和局部内存管理
    [转]
    [转]
    [转]
    The Stable Marriage Problem
    STL各种容器的使用时机详解
    Qt中图像的显示与基本操作
  • 原文地址:https://www.cnblogs.com/love007/p/2701822.html
Copyright © 2020-2023  润新知