我正試圖編寫一個簡單的服務,它將採用ItemAttachments
並將它們移動到任意Microsoft.Exchange.WebServices.Data.Folder
。這可以做到嗎?我正在使用Exchange 2010 SP2。如何使用EWS託管API將ItemAttachments移動到文件夾2
下面的代碼生成一個System.InvalidOperationException
:「此操作不支持附件」
private void ProcessItem(ItemId id, Folder folder)
{
Item envelope = Item.Bind(_ExchangeService, id, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Attachments));
if (envelope.HasAttachments && envelope.Attachments[0] is ItemAttachment)
{
ItemAttachment attachedItem = envelope.Attachments[0] as ItemAttachment; // always only one
attachedItem.Load(new PropertySet(ItemSchema.ItemClass));
Item itemToMove = attachedItem.Item;
try
{
itemToMove.Move(folder.Id); //this is the bad boy!
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
throw;
}
}
}
任何建議或幫助,將不勝感激。