切换到宽版
  • 13331阅读
  • 2回复

EXCHANGE 创建约会邀请,时区设置有问题。大家讨论下 [复制链接]

上一主题 下一主题
 
只看楼主 倒序阅读 0楼  发表于: 2012-09-23

try{
   //实例化一个Appointment
   Appointment appointment = new Appointment(service);
   //约会主题
   appointment.setSubject("2012年9月财务会议");
   //约会内容
   MessageBody body = new MessageBody();
   body.setBodyType(BodyType.Text);//文本类型
   body.setText("经董事局决定,于2012年9月召开会议");
   appointment.setBody(body);
      
  
  
   //与会时间
   Calendar cal = Calendar.getInstance();//使用默认时区和语言环境获得一个日历。  
   //时区设置
      Collection<TimeZoneDefinition> t = service.getServerTimeZones();
      TimeZoneDefinition tf = null;
      for (TimeZoneDefinition timeZoneDefinition : t) {
       if (timeZoneDefinition.getId().equals(cal.getTimeZone().getID())) {
        System.out.println("xx="+timeZoneDefinition.getName());
        tf = timeZoneDefinition;
        break;
       }
      
      }
      SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      Date startDate = formatter.parse("2012-09-25 14:20:12");
      Date endDate = formatter.parse("2012-09-25 16:20:12");
      appointment.setStart(startDate);
      appointment.setEnd(endDate);
    appointment.setStartTimeZone(tf);
    //appointment.setEndTimeZone(tf);
            /**
      System.out.println("Start=="+cal.getTime());
   appointment.setStart(cal.getTime());
   appointment.setStartTimeZone(tf);
   cal.add(Calendar.DATE, 4);
   System.out.println("enddate=="+cal.getTime());
   appointment.setEnd(cal.getTime());
   appointment.setEndTimeZone(tf);
   **/
   //地址
   appointment.setLocation("北京海淀区会议室");
   EmailAddress emails = new EmailAddress();
   emails.setAddress("ss@qq.com");
   appointment.save();
   appointment.forward(body, emails);

  }catch(Exception e){
   e.printStackTrace();
  }
分享到
只看该作者 1楼  发表于: 2012-09-23

microsoft.exchange.webservices.data.ServiceLocalException: The time zone definition is invalid or unsupported.
    at microsoft.exchange.webservices.data.TimeZoneDefinition.validate(Unknown Source)
    at microsoft.exchange.webservices.data.PropertyBag.validatePropertyValue(Unknown Source)
    at microsoft.exchange.webservices.data.PropertyBag.validate(Unknown Source)
    at microsoft.exchange.webservices.data.ServiceObject.validate(Unknown Source)
    at microsoft.exchange.webservices.data.Item.validate(Unknown Source)
    at microsoft.exchange.webservices.data.Appointment.validate(Unknown Source)
    at microsoft.exchange.webservices.data.CreateItemRequest.validate(Unknown Source)
    at microsoft.exchange.webservices.data.ServiceRequestBase.validateAndEmitRequest(Unknown Source)
    at microsoft.exchange.webservices.data.SimpleServiceRequestBase.internalExecute(Unknown Source)
    at microsoft.exchange.webservices.data.MultiResponseServiceRequest.execute(Unknown Source)
    at microsoft.exchange.webservices.data.ExchangeService.internalCreateItems(Unknown Source)
    at microsoft.exchange.webservices.data.ExchangeService.createItem(Unknown Source)
    at microsoft.exchange.webservices.data.Item.internalCreate(Unknown Source)
    at microsoft.exchange.webservices.data.Item.save(Unknown Source)
    at com.icss.hony.mip.test.EwsAppointmentTest.main(EwsAppointmentTest.java:76)
只看该作者 2楼  发表于: 2012-11-23
在吗,想问你个问题,你再创建会议邀请的时候,本人的日历中能否收到日历?


  //  Appointment appointment = new Appointment(_service);//约会主题
  //      appointment.Subject = "Play Basketball";//约会内容
  //      appointment.Body = "Play Basketball";//约会开始时间2010-6-1 12:30:00
  //      appointment.Start = new DateTime(2012,11,22,13,20,0);//约会结束
  //      appointment.End = appointment.Start.AddHours(2);//约会的位置
  
  //      appointment.Location = "蓝罐会议室";
        
  //      appointment.RequiredAttendees.Add("bennyzhang@rich.com");
        
  //     // appointment.RequiredAttendees.Add("rcao@rich.com");
    
  //      appointment.Save( SendInvitationsMode.SendToAllAndSaveCopy);
快速回复
限60 字节
 
上一个 下一个