我正在使用Exchange Web服务托管API。我正在添加一个扩展属性,以便在收件箱中邮寄邮件时,它们会根据某些条件进行处理。因此,并非所有的邮件都会得到这个扩展属性。无法获取电子邮件的内置属性以及扩展属性
接下来,我正在重新提取收件箱中的所有邮件,如果他们将此属性附加到他们,我再处理它们。
下面是一个简单的方法getAllMailsInInbox()
,我曾写信给重新读取该邮件在收件箱:
class MyClass
{
private static Guid isProcessedPropertySetId;
private static ExtendedPropertyDefinition isProcessedPropertyDefinition = null;
static MyClass()
{
isProcessedPropertySetId = new Guid("{20F3C09F-7CAD-44c6-BDBF-8FCB324244}");
isProcessedPropertyDefinition = new ExtendedPropertyDefinition(isProcessedPropertySetId, "IsItemProcessed", MapiPropertyType.String);
}
public List<EmailMessage> getAllMailsInInbox()
{
List<EmailMessage> emails = new List<EmailMessage>();
ItemView itemView = new ItemView(100, 0);
FindItemsResults<Item> itemResults = null;
PropertySet psPropSet = new PropertySet(BasePropertySet.IdOnly);
itemView.PropertySet = psPropSet;
PropertySet itItemPropSet = new PropertySet(BasePropertySet.IdOnly,
ItemSchema.Attachments,
ItemSchema.Subject,
ItemSchema.Importance,
ItemSchema.DateTimeReceived,
ItemSchema.DateTimeSent,
ItemSchema.ItemClass,
ItemSchema.Size,
ItemSchema.Sensitivity,
EmailMessageSchema.From,
EmailMessageSchema.CcRecipients,
EmailMessageSchema.ToRecipients,
EmailMessageSchema.InternetMessageId,
ItemSchema.MimeContent,
isProcessedPropertyDefinition); //***
itemResults = service.FindItems(WellKnownFolderName.Inbox, itemView);
service.LoadPropertiesForItems(itemResults.Items, itItemPropSet);
String subject = itItem.Subject; //Exception: "You must load or assign this property before you can read its value."
//....
}
}
正如你所看到的,随叫随到service.LoadPropertiesForItems()
,这不加载任何特性,从而导致You must load or assign this property before you can read its value.
异常而访问任何这些属性。
如果我从itItemPropSet
属性集中删除isProcessedPropertyDefinition
,它会正确提取所有属性。
所以我可以只知道如何获取所有内置EmailMessage属性以及扩展属性?
对不起,我在编写问题时只是操纵了GUID。别管它。 – Mahesha999