How extract email address from IPM.Note?

  • Thread starter Thread starter Chris Shearer Cooper
  • Start date Start date
C

Chris Shearer Cooper

I want to let people drag a contact from Outlook (and eventually Outlook
Express) onto my program, and then extract the name & email address.

I'm able to use OpenIMsgOnIStg to get the IMessage, and then I'm extracting
properties like PR_MESSAGE_CLASS (which is "IPM.Note" for Outlook contacts)
and PR_DISPLAY_NAME (which is what it sounds like). However, I've
enumerated the properties, and the email address contained in the Outlook
contact is stored in some strange properties like PR_EMS_AB_HOME_MDB and
PR_EMS_AB_MANAGER.

Are those the right properties for me to use? Or is there a more "correct"
way to extract the email address from an Outlook contact?

Thanks,
Chris
 
You are hitting named propertiers (tags >=0x80000000) - before accessing
such properties, call IMessage::GetIDsFromNames passing the right GUID and
id to get the prop tag.
You can figure out GUIDs and ids using OutlookSpy: select the item in
question in Outlook and click Imessage button. Select the named property you
are after and look at the "Named Property" box on thee right hand side.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Outlook Spy is very cool!

But ... when I look at a contact in Outlook, there is a property with tag
num 0x8022001E and OOM "Email1Address" which contains the value that I want,
but when I drag & drop into my application, the property with tag ID 0x8022
is of type PT_BOOLEAN instead of PT_STRING8.

I guess what it packages up for drag & drop isn't the same as what you get
inside of Outlook.

Any ideas?

Thanks!
Chris
 
Correct. The value of the property tag will be different in different stores
or MSG files.
That's the whole point of named properties: the prop tag is guaranteed to be
unique for the given GUID and id.
*Do* call IMessage::GetIDsFromNames, "or" the returned tag with the correct
property type (e.g. PT_STRING8), then use it to call GetProps/HrGetOneProp.
Do *not* hardcode the prop tag value.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Gotcha ... but I think that not only is the property tag different in
different stores, so is the GUID. Here's what I did.

I called GetIDsFromNames, passing it a single MAPINAMEID with the GUID I saw
for it in Outlook Spy, ulKind=MNID_STRING, and Kind.lpwstrName =
L"Email1Address". The call succeeded, but the returned value is 0x0000000A
(PT_ERROR).

Is there a way that I can ask, for a given property that I see in the array
returned by GetPropList, which property set (GUID) he belongs to?

Can I enumerate the property sets that the IMessage knows about?

BTW, I think I'm safe to hardcode things like PR_DISPLAY_NAME, they seem to
be fixed ... right?

Thanks!
Chris
 
1. No, Email1Address is MNID_ID with the GUID of
{00062004-0000-0000-C000-000000000046} and id of (integer, not string!)
0x8083. This is what OutlookSpy shows in the "Named Property" box when you
select that named property.
"Email1Address" is what it is called by Outlook Object Model. That name is
never passed to MAPI, it is just an FYI.
2. Yes, call IMessage::GetNamesFromIDs. There is no need to do though: the
GUID and id stay the same for a given property.
3. Correct. You only need GetIDsFromNames for the named (tags >= 0x80000000)
properties (shown in bold by OutlookSpy).

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
So I made some more progress, I may have gotten to the point that I know
what question I need to ask!

I added a second email address to my Outlook contact, just so I could see
what happened. The second email address show up as tag num 0x8026001E, ID
0x8093, OOM "Email2Address", GUID {00062004-0000-0000-C000-000000000046},
and also tag num 0x8027001E, ID 0x8094, OOM "EMail2DisplayName", GUID
{00062004-0000-0000-C000-000000000046}.

Where are you getting those OOM names from?

I call GetPropList on my IMessage, and then for each property tag it
returns, I call GetNamesFromIDs and GetProps. I see that second email
address (value returned from GetProps) in two places - tag num 0x800F001E
and tag num 0x8010001E. When I call GetNamesFromIDs, passing it 0x800F001E,
it returns ID 0x8093 - which is good!

So if I understand this correctly, the tag number (0x8026001E or 0x800F001E)
can change, but the ID (0x8093) cannot? And properties have to have
either a specific ID number or a specific name, but not both?

Do you know if this ID number (0x8093) is documented anywhere?

Thanks!
Chris
 
1. OOM names are not documented anywhere, if that's what you mean.
OutlookSpy juts check the prop tags against a hardcoded lists of GUIDs and
ids.
2. Why do you need to call GetPropList or GetNamesFromIDs? If you only need
to retrieve a set of properties, GetIDsFromNames followed by
GetProps/HrGetOneProp is all you need.
3. Correct, GUID and id are constant, prop tag is not.
4. Nope, neither 0x8093 nor any other named props are documented by MS.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Back
Top