Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在EWS api的帮助下,使用java创建带有附件的Outlook日历定期会议_Java_C#_Automation_Exchangewebservices - Fatal编程技术网

在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

在EWS api的帮助下,我使用java创建了Outlook日历定期会议附件。我的会议已成功创建,组织者帐户中有附件,但接收者收到相同的会议请求,日历中没有附件。 我想我的脚本中缺少了一些东西。请看一下脚本,并建议我可以改进的地方

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;
}