Get named MAPI Property from MailItem in C#

时光毁灭记忆、已成空白 提交于 2019-12-02 02:56:40

问题


I'm developing an Outlook 2010 custom plugin in C#. This is my first time using C# (I'm a java guy normally).

There is a named (custom) MAPI property on a message that I would like to access and am having trouble doing so. My understanding is that in Outlook 2007 the PropertyAccessor object was introduced which allows easy access to named MAPI properties. I followed the instructions from the following documentation:

http://msdn.microsoft.com/en-us/library/ff868915.aspx

I can see the named MAPI property I want to access on the message using Outlook Spy. From Outlook Spy I can get the following information about the property:

GUID:    {00020329-0000-0000-C000-000000000046}
Tag num: 0x80BE0102
ID:      PR.AFU.MESSAGE.RETRIEVE.INFO
Type:    PT_BINARY

So I tried the following code (Object mail is a valid instance of MailItem):

mail.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/id/{00020329-0000-0000-C000-000000000046}/80BE0102");

This produces the following exception:

The property "http://schemas.microsoft.com/mapi/id/{00020329-0000-0000-C000-000000000046}/80BE0102" is unknown or cannot be found

So I'm wondering how to actually get this property? Am I forming the namespace reference incorrectly? Or do I need to use an approach as outlined in this example:

http://www.outlookcode.com/codedetail.aspx?id=1112

My understanding was that this was only necessary for pre 2007 versions of Outlook. Any help is much appreciated!


回答1:


OutlookSpy will give you the DASL property name in the DASL edit box in the IMessage window.




回答2:


What happens if you try

mail.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x80BE0102");

?




回答3:


Microsoft's MFCMapi is also a great tool to locate the DASL and view all MAPI properties.



来源:https://stackoverflow.com/questions/6862325/get-named-mapi-property-from-mailitem-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!