我在EWS api的帮助下使用java创建了Outlook Calendar Recurring会议。我的会议使用组织者帐户中的附件成功创建,但接收者在其日历中获得相同的会议请求没有附件。 我想我的脚本中缺少一些东西请看一下脚本并建议我可以改进的地方
public static void sendRecurringDailyAppointmentswithAttachment(String
appSubject, String appBody, int count, String recipient, String[]
attachment) {
ExchangeService sv = service();
try {
Appointment app =
prepareRecurringDailyAppointmentwithAttachment(appSubject, appBody, count,
sv, attachment );
app.getRequiredAttendees().add(recipient);
app.save();
} catch (Exception e) {
e.printStackTrace();
}
}
private static Appointment
prepareRecurringDailyAppointmentwithAttachment(String appSubject, String
appBody, int count, ExchangeService sv, String[] attachment) throws {
Appointment app = new Appointment(sv);
app.setSubject(appSubject);
app.setBody(MessageBody.getMessageBodyFromText(appBody));
app.setStart(getNextHourDate());
app.setEnd(getDateWithHourDelta(2));
app.getAttachments();
if (attachment != null){
for (String fileName : attachment){
System.out.println("... adding attachment " + fileName);
app.getAttachments().addFileAttachment(fileName);
}
}
app.setRecurrence(new Recurrence.DailyPattern(app.getStart(), 1));
app.getRecurrence().setStartDate(app.getStart());
app.getRecurrence().setNumberOfOccurrences(count);
return app;
}
答案 0 :(得分:0)
我认为您需要首先使用附件保存约会:
if (attachment != null){
for (String fileName : attachment){
System.out.println("... adding attachment " + fileName);
app.getAttachments().addFileAttachment(fileName);
}
app.save();
然后添加与会者并进行更新:
app.getRequiredAttendees().add(recipient);
app.update(ConflictResolutionMode.AutoResolve, SendInvitationsOrCancellationsMode.SendOnlyToAll);
答案 1 :(得分:0)
public static void sendRecurringDailyAppointmentswithAttachment(String
appSubject, String appBody, int count, String recipient, String[]
attachment) {
ExchangeService sv = service();
try {
Appointment app =
prepareRecurringDailyAppointmentwithAttachment(appSubject, appBody, count,
sv, attachment );
app.getRequiredAttendees().add(recipient);
app.update(ConflictResolutionMode.AutoResolve);
} catch (Exception e) {
e.printStackTrace();
}
}
private static Appointment
prepareRecurringDailyAppointmentwithAttachment(String appSubject, String
appBody, int count, ExchangeService sv, String[] attachment) throws {
Appointment app = new Appointment(sv);
app.setSubject(appSubject);
app.setBody(MessageBody.getMessageBodyFromText(appBody));
app.setStart(getNextHourDate());
app.setEnd(getDateWithHourDelta(2));
app.getAttachments();
if (attachment != null){
for (String fileName : attachment){
System.out.println("... adding attachment " + fileName);
app.getAttachments().addFileAttachment(fileName);
}
app.save();
}
app.setRecurrence(new Recurrence.DailyPattern(app.getStart(), 1));
app.getRecurrence().setStartDate(app.getStart());
app.getRecurrence().setNumberOfOccurrences(count);
return app;
}