在约会EWS(Exchange Web服务)中向不同的收件人发送不同的附件

时间:2016-09-29 06:42:16

标签: c# exchangewebservices

我正在尝试通过EWS的预约课程发送会议邀请。 我需要向不同的收件人发送不同的附件。我正在引用以下链接:

https://social.msdn.microsoft.com/Forums/exchange/en-US/cf4b9d9a-7bbb-4caa-9d55-300371fa84ac/ews-attachment-not-sent-with-invitation

此链接仅适用于发送一个或多个附件,但我需要每个收件人都应该有不同的附件。

我正在尝试遵循我的代码,这可能有助于更好地理解挑战:

Appointment appointment = new Appointment(service) {
  Start = DateTime.Now,
    End = DateTime.Now.AddHours(2),
    Subject = "XYZ Invitation",
    Location = "XYZ Tower, Room No. 3",
    IsAllDayEvent = false,
    AllowNewTimeProposal = false,
    IsResponseRequested = false,
    Body = new MessageBody(BodyType.HTML, html),
    ReminderMinutesBeforeStart = 60

};

int i = 0;
foreach(var attendee in attendies) { // List<string> 
  appointment.Attachments.AddFileAttachment(Image[i], file);
  appointment.Attachments[0].IsInline = true;
  appointment.Attachments[0].ContentId = Image[i];

  FolderId folderCalendar = new FolderId(WellKnownFolderName.Calendar, attendee);
  appointment.Save(folderCalendar, SendInvitationsMode.SendToNone);

  appointment.RequiredAttendees.Add(attendee);
  i++;

  appointment.Update(ConflictResolutionMode.AutoResolve, SendInvitationsOrCancellationsMode.SendOnlyToAll);
}

如果有人有相同的经验,请建议我。

提前致谢!

1 个答案:

答案 0 :(得分:1)

您必须使用约会类的绑定方法,才能第二次发送不同的附件以添加收据。

appointment.Bind(ExchangeService, ItemId, PropertySet);

绑定到现有约会并加载指定的属性集。调用此方法会导致调用Exchange Web服务(EWS)。

我希望它可以帮到你。