zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Good Bye 2014 B. New Year Permutation(floyd )
    hdu 5147 Sequence II (树状数组 求逆序数)
    POJ 1696 Space Ant (极角排序)
    POJ 2398 Toy Storage (叉积判断点和线段的关系)
    hdu 2897 邂逅明下 (简单巴什博弈)
    poj 1410 Intersection (判断线段与矩形相交 判线段相交)
    HDU 3400 Line belt (三分嵌套)
    Codeforces Round #279 (Div. 2) C. Hacking Cypher (大数取余)
    Codeforces Round #179 (Div. 2) B. Yaroslav and Two Strings (容斥原理)
    hdu 1576 A/B (求逆元)
  • 原文地址:https://www.cnblogs.com/love007/p/2701822.html
Copyright © 2011-2022 走看看