我试图在EmailMessage
对象中迭代附件。
我收到错误"附件无法更新"在这一行:
fa.ContentId = fa.Id;
我的代码是:
EmailMessage emailMsg = EmailMessage.Bind(service, new ItemId(emailId), new PropertySet(BasePropertySet.IdOnly, ItemSchema.Attachments,ItemSchema.Body,ItemSchema.DateTimeReceived,EmailMessageSchema.DisplayCc,EmailMessageSchema.DisplayTo,EmailMessageSchema.Subject,EmailMessageSchema.From));
this.Email = msgItem;
this.Email.Load();
// make sure email has id or contentid
foreach (Attachment attachment in this.Email.Attachments)
{
FileAttachment fa = attachment as FileAttachment;
if (fa.ContentId == null && fa.Id != null)
{
fa.Load();
fa.ContentId = fa.Id; // error attachments can't be updated
}
}
由于
答案 0 :(得分:0)
您无法更新现有Exchange项目上的附件,例如,唯一有效的附件操作是获取,创建,删除没有更新。您可以设置ContentId的唯一有效上下文是在CreateAttachment操作中创建此属性的Message时。要更新现有附件,您必须将其删除,然后将其重新添加为新附件。您实际尝试使用代码实现的目标是什么?
干杯 格伦