java - 在 EWS api 的帮助下使用 java 创建带有附件的 Outlook 日历定期 session

标签 java c# automation exchangewebservices

我在 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/

相关文章:

javascript - 如何检索 javascript 文件中的所有函数名称

java - IntentService确实广播但onReceive没有收到广播

c# - 对 servicestack ormlite 中的所有结果进行分页

c# - 使用泛型的抽象类对成员进行 XML 序列化

ruby - 使用 Watir 自动进行身份验证

deployment - 使用 CLI 自动设置 jenkins 用户

java - Springboot同步方法

java - 为什么java在方法调用中没有参数的默认值

java - ListView setAdapter() 空指针异常(使用 Inflator)

c# - 我可以使用 ajax 调用 C# 代码隐藏方法吗?