0
我有一個功能可以在一個子文件夾中複製電子郵件,也可以在多個附件的情況下應用一個類別。在複製的郵件上綁定
void CopyInSubfolder(EmailMessage email, bool categorize)
{
PropertySet propSet = new PropertySet(BasePropertySet.IdOnly, EmailMessageSchema.ParentFolderId);
Item item = email.Copy(_subFolder);
EmailMessage copiedMessage = EmailMessage.Bind(service, item.Id, propSet);
if (categorize)
copiedMessage.SetCategory("MULTIPLE ATTACHMENTS");
}
是SetCategory
一個簡單的擴展方法:
public static void SetCategory(this EmailMessage pContainer, string pCategory)
{
StringList ExistingCategories = pContainer.Categories;
if(!ExistingCategories.Contains(pCategory))
{
ExistingCategories.Add(pCategory);
}
pContainer.Update(ConflictResolutionMode.AutoResolve);
}
的問題是,當我嘗試運行的CopiedMessage
項目SetCategory
方法,我總是得到一個空StringList
對象,無論多少消息已有的現有類別。如果我嘗試調用原始郵件上的方法,它會按預期工作,所以我想我無法綁定到複製的郵件。我使用this how-to article on MSDN作爲複製部分。