/**
* Meeting:创建重复约会
*/
private void createRecurringAppointment(String userName, String password, String domain, String subject, String location, String startsTime, String endsTime, String recurrenceType, String recurrenceEndsDate, String body, boolean isAllDay) {
EWS ews = new EWS();
ExchangeService service = ews.connectEWS(userName, password, domain);
try {
Appointment appointment = new Appointment(service);
// 中国标准时间
TimeZoneDefinition tz = getTimeZoneDefinition(service, TIME_ZONE_CTT);
appointment.setSubject(subject); // 约会标题
appointment.setLocation(location); // 约会地点
appointment.setBody(MessageBody.getMessageBodyFromText(body)); // 约会正文
// 约会开始时间和结束时间
HashMap<String, Date> times = getStartsAndEndsTime(startsTime, endsTime);
appointment.setStart((Date) times.get("startsTime"));
appointment.setStartTimeZone(tz);
appointment.setEnd((Date) times.get("endsTime"));
appointment.setEndTimeZone(tz);
// 约会循环类型
Date dateRecurrenceStarts = appointment.getStart();
Date dateRecurrenceEnds = getRecurrenceEndsDate(recurrenceEndsDate);
Recurrence recurrences = null;
switch(recurrenceType.toLowerCase()) {
case "daily":
recurrences = new Recurrence.DailyPattern(dateRecurrenceStarts, 1); // 默认interval为1天
break;
case "weekly":
/**
* @param 重复会议开始日期
* @param 重复间隔为一周一次
* @param 重复会议发生在每周星期一
*/
recurrences = new Recurrence.WeeklyPattern(dateRecurrenceStarts, 1, DayOfTheWeek.Monday); // 默认每周一
break;
case "monthly":
/**
* @param 重复会议开始日期
* @param 重复间隔为一月一次
* @param 重复会议发生在每月一号
*/
recurrences = new Recurrence.MonthlyPattern(dateRecurrenceStarts, 1, 1); // 默认每月一号
break;
case "yearly":
/**
* @param 重复会议开始日期
* @param 重复间隔为一年一次
* @param 重复会议发生在每年六月一号
*/
recurrences = new Recurrence.YearlyPattern(dateRecurrenceStarts, Month.June, 1); // 默认每年六月一号
break;
default:
System.out.println("输入无效!");
break;
}
appointment.setRecurrence(recurrences);
appointment.getRecurrence().setStartDate(dateRecurrenceStarts);
appointment.getRecurrence().setEndDate(dateRecurrenceEnds);
appointment.setIsAllDayEvent(isAllDay); // 是否全天事件
appointment.save(WellKnownFolderName.Calendar, SendInvitationsMode.SendToNone);
} catch (Exception e) {
System.out.println("Error: Fail to create appointment!");
e.printStackTrace();
}
}
ews-java-api学习:新建Recurring Appointment
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 影子 在学习Spring WebFlux之前,我们先来了解JDK的Stream,虽然他们之间没有直接的关系,有趣的...
- 今天有网友问我这个问题,我将回答的内容分享给我简书上的朋友们。 想建立学习能力,其实无论何时开始都不晚。 但必须要...