我使用的是EWSJavaAPI1.2,使用这段代码保存ItemAttachment有问题。
if(attachmentsCol.getPropertyAtIndex(i) instanceof FileAttachment)
{
...
}
else
{
ItemAttachment attachment = (ItemAttachment)attachmentsCol.getPropertyAtIndex(i);
attachment.load();
Item item = attachment.getItem();
item.load(newPropertySet(ItemSchema.MimeContent));`
MimeContent Itemmc = item.getMimeContent();
....
} item.load(....)返回此错误
microsoft.exchange.webservices.data.InvalidOperationException:无法执行此操作,因为此服务对象没有Id。
谢谢你的帮助。
发布于 2014-10-03 04:30:45
您不能对ItemAttachment本身执行加载,因为这将尝试执行对附件无效的GetItem请求。您需要做的是在Attachment.load()上包含一个带有Mime的属性集,例如
foreach (var item in findResults.Items)
{
foreach (Attachment Attach in item.Attachments) {
if (Attach is ItemAttachment) {
PropertySet psProp = new PropertySet(BasePropertySet.FirstClassProperties);
psProp.Add(ItemSchema.MimeContent);
((ItemAttachment)Attach).Load(psProp);
if (((ItemAttachment)Attach).Item.MimeContent != null)
{
System.IO.File.WriteAllBytes("c:\\temp\\file.eml", ((ItemAttachment)Attach).Item.MimeContent.Content);
}
}
} 干杯格伦
https://stackoverflow.com/questions/26163968
复制相似问题