Home > Blockchain >  Risks associated with using DASL property name (http://schemas.microsoft.com URL) with Outlook.Prope
Risks associated with using DASL property name (http://schemas.microsoft.com URL) with Outlook.Prope

Time:09-21

I am coding a VSTO add-in for Outlook, and in order to access MailItem properties that are not exposed by the Outlook Object Model (such as email header text) the approach put-forth by Microsoft (and here on stackoverflow) is to use code like the following, that has a "http://schemas.microsoft.com" URL:

Outlook.PropertyAccessor oPA = msg.PropertyAccessor as Outlook.PropertyAccessor;
    const string PR_MAIL_HEADER_TAG = @"http://schemas.microsoft.com/mapi/proptag/0x007D001E";
    try
    {
        string strHeaders = (string)oPA.GetProperty(PR_MAIL_HEADER_TAG);
    }
    catch { }

I am trying to understand what the GetProperty method is doing with the http://schemas.microsoft.com URL, and the documentation I found (here and here) has been less than helpful.

Am I correct that these URLs are just labels used to access different object namespaces?
If that's the case, why are they in an http URL format? Will my compiled executable actually reach out to the Internet to grab some info at this URL?

Typing that address into a web browser brings up the message: "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable." So -- it would appear not?

Or is it using the URL to look up a locally stored HTTP document -- that the compiler inserts into the assembly similar to a resource file?

Either way -- what information is the PropertyAccessor.GetProperty method using based on the URL that is passed to it?

I'm leery about using the PropertyAccessor.GetProperty method, especially if it is in fact actually reaching out to the Internet... so any guidance on this, or additional sources I could look-to would be greatly appreciated.

CodePudding user response:

Yes, it is just a label - no network connection is ever made. Think of the DASL name as a unique (to Microsoft) property name prefix used by the Outlook Object Model, Exchange Web Services (EWS), and Graph.

In Extended MAPI, a property tag is just a 4 byte unsigned int, with the upper two bytes being the property id and the lower two bytes are the property tag: i.e. PR_SUBJECT_W is 0x0037001F. 0x0037 is the property id, and 0x001F is the property type (PT_UNICODE in this case). Properties <= 0x7FFFFxxxx are fixed properties (their property id never changes), and properties >= 0x80000000 are named properties: their property id is determined at run time based on the named property GUID and some id (either string or an integer) - this is done to support custom properties without the risk of property id collision: the client app is expected to call IMAPIProp::GetIdsFromNames() and pass a list of guids and ids, and get back property ids guaranteed to uniquely map to the given guid/id/name in the particular message store.

DASL property names are designed to hide that complexity, for PR_SUBJECT_W above, its DASL property name is "http://schemas.microsoft.com/mapi/proptag/0x0037001F". For the named properties it is slightly different. E.g. for the named property commonly known as SmartNoAttach (GUID={00062008-0000-0000-C000-000000000046} - which is PSETID_Common, id = 0x8514, and property type of PT_BOOLEAN), the DASL name is "http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8514000B" - note the 8514000B part: it is id = 0x8514, and 0x000B is PT_BOOLEAN type. If the id is a string rather than an int, the format is slightly different - e.g. http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/Keywords/0x0000101F" for the named property used to store the message categories.

Some common properties can be represented by other names, e.g. you can alternatively use "urn:schemas:mailheader:keywords" or "urn:schemas:mailheader:keywords" for the Categories property above.

With the DASL property name, you can safely hardcode its string representation (unlike the named property integer tag, which can differ for different message stores even in the same profile).

You can take a look at the existing MAPI property tags and their DASL names in OutlookSpy (I am its author) - click IMessage button to see property tags, DASL names, and property values.

  • Related