我在 EWS api 的帮助下使用 java 创建了带有附件的 Outlook 日历定期 session 。我的 session 使用组织者帐户中的附件成功创建,但接收者在他的日历中收到相同的 session 请求没有附件。 我想我的脚本中遗漏了一些东西,请查看脚本并建议我可以改进的地方
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;
}
最佳答案
我认为你需要先用附件保存约会:
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);
关于java - 在 EWS api 的帮助下使用 java 创建带有附件的 Outlook 日历定期 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44983579/