0
我想將我的電子郵件附件移動/複製到Outlook中的新文件夾中/並且我的代碼無法正常工作。將電子郵件附件移動到Outlook中的另一個文件夾中
foreach(Item item in findResults.Items)
{
EmailMessage email = EmailMessage.Bind(service, item.Id, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Attachments));
if(false)
{
// OTC Marker HTML Body
}
else
{
if (email.HasAttachments)
{
foreach (Attachment attachment in email.Attachments)
{
EmailMessage emailAttachment = EmailMessage.Bind(service, attachment.Id, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Attachments));
ItemAttachment itemAttachment = attachment as ItemAttachment;
itemAttachment.Load();
EmailMessage mess = itemAttachment.Item as EmailMessage;
moveToTestFolder (mess, @"TestFolder");
}
}
else
{
//to do
}
}
}
而且我moveToTestFolder方法:
private void moveToTestFolder (EmailMessage item, string folderName)
{
Folder rootfolder = Folder.Bind(service, WellKnownFolderName.MsgFolderRoot);
rootfolder.Load();
var folders = rootfolder.FindFolders(new FolderView(20));
var folderItemToMove = folders.FirstOrDefault(f => f.DisplayName.Equals(folderName, StringComparison.OrdinalIgnoreCase));
item.Move(folderItemToMove.Id);
}
我'嘗試移動附件(如果是電子郵件)的特殊文件夾中的前景。移動正常信息現在正在工作。
您需要說明「無法正常工作」的含義。 – Filburt 2014-10-22 07:42:22
我的意思是什麼都沒有發生;/ – PiotrKowalski 2014-10-22 07:45:41
你是否嘗試用調試器來調試你的方法?如果什麼都沒有發生,我很肯定你正在捕捉和吞嚥你的代碼中某處出現的異常。 – Filburt 2014-10-22 08:12:04