在EWS api的帮助下,使用java创建带有附件的Outlook日历定期会议
在EWS api的帮助下,我使用java创建了Outlook日历定期会议附件。我的会议已成功创建,组织者帐户中有附件,但接收者收到相同的会议请求,日历中没有附件。 我想我的脚本中缺少了一些东西。请看一下脚本,并建议我可以改进的地方在EWS api的帮助下,使用java创建带有附件的Outlook日历定期会议,java,c#,automation,exchangewebservices,Java,C#,Automation,Exchangewebservices,在EWS api的帮助下,我使用java创建了Outlook日历定期会议附件。我的会议已成功创建,组织者帐户中有附件,但接收者收到相同的会议请求,日历中没有附件。 我想我的脚本中缺少了一些东西。请看一下脚本,并建议我可以改进的地方 public static void sendRecurringDailyAppointmentswithAttachment(String appSubject, String appBody, int count, String recipient, String
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);
谢谢你的反馈,现在我得到了结果。
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;
}