PC Review


Reply
Thread Tools Rate Thread

Can't get SMTP address of contact that shares email address of an Exchange user

 
 
Jeff
Guest
Posts: n/a
 
      20th Apr 2007
I created a contact in Outlook 2003, then I gave that contact an email
address that matches the email address of an Exchange user. When I
access this contact using Outlook COM, I now get the Exchange address
("//o=Company/ou=First Administrative Group/cn=Recipients/cn=0001234")
instead of the address I typed into the contact ("(E-Mail Removed)").

I implemented Ken Slovak's suggestions "To get the SMTP address
instead of the Exchange distinguished name", found here (http://
groups.google.com/group/microsoft.public.outlook.program_vba/
browse_thread/thread/60231601429b1156/811ce165ff5854df?lnk=st&q=outlook
+com+get+smtp+email+address+of+contact&rnum=3#811ce165ff5854df)

I also implemented Dmitry's instructions "Default SMTP address of an
Exchange user" found here (http://www.dimastr.com/redemption/
utils.htm)

I think those instructions don't apply b/c of the fact that the
ContactItem i created isn't really an Exchange user, but merely shares
an email address w/ an Exchange user.

I know how to get the SMTP addresses from a MailItem, so please don't
give me help with that.

Any ideas?

Thanks in advance!
Jeff

Here's (C#) code that illustrates the problem. I included the return
values in the comments:

//get the contact I created for this test...
Microsoft.Office.Interop.Outlook.Application app = new
Microsoft.Office.Interop.Outlook.Application();
NameSpace ns = app.GetNamespace("MAPI");
Microsoft.Office.Interop.Outlook.MAPIFolder folder =
ns.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
ContactItem contact = folder.Items[1] as ContactItem;
MAPIUtils utils = new MAPIUtils();

//define properties...
int PR_EMS_AB_PROXY_ADDRESSES = unchecked((int)0x800f101e);
const int g_PR_SMTP_ADDRESS_W = unchecked((int)0x39FE001E);

//analyze the ContactItem
string emailAddress = contact.Email1Address;//o=Company/ou=First
Administrative Group/cn=Recipients/cn=0001234
string emailAddressType = contact.Email1AddressType;//EX
object contactProp1 = utils.HrGetOneProp(contact.MAPIOBJECT,
PR_EMS_AB_PROXY_ADDRESSES);//null
object contactProp2 = utils.HrGetOneProp(contact.MAPIOBJECT,
g_PR_SMTP_ADDRESS_W);//null

//analyze the AddressEntry
Redemption.AddressEntry addressEntry =
utils.GetAddressEntryFromID(contact.EntryID) as
Redemption.AddressEntry;
string addressEntryAddress = addressEntry.Address;//null
object addressEntryProp1 = utils.HrGetOneProp(addressEntry.MAPIOBJECT,
PR_EMS_AB_PROXY_ADDRESSES);//null
object addressEntryProp2 = utils.HrGetOneProp(addressEntry.MAPIOBJECT,
g_PR_SMTP_ADDRESS_W);//null

 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      20th Apr 2007
The Exchange address is really only valid for an entry in the GAL. If you
have a contact that shares that address with the GAL entry then you might be
able to do what you've done but otherwise it's useless. Just change the
contact address to the SMTP version and forget about using an X.400 address
for that. The MAPI fields you mention are only there for Recipients or
AddressEntries that correspond to GAL entries.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Jeff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I created a contact in Outlook 2003, then I gave that contact an email
> address that matches the email address of an Exchange user. When I
> access this contact using Outlook COM, I now get the Exchange address
> ("//o=Company/ou=First Administrative Group/cn=Recipients/cn=0001234")
> instead of the address I typed into the contact ("(E-Mail Removed)").
>
> I implemented Ken Slovak's suggestions "To get the SMTP address
> instead of the Exchange distinguished name", found here (http://
> groups.google.com/group/microsoft.public.outlook.program_vba/
> browse_thread/thread/60231601429b1156/811ce165ff5854df?lnk=st&q=outlook
> +com+get+smtp+email+address+of+contact&rnum=3#811ce165ff5854df)
>
> I also implemented Dmitry's instructions "Default SMTP address of an
> Exchange user" found here (http://www.dimastr.com/redemption/
> utils.htm)
>
> I think those instructions don't apply b/c of the fact that the
> ContactItem i created isn't really an Exchange user, but merely shares
> an email address w/ an Exchange user.
>
> I know how to get the SMTP addresses from a MailItem, so please don't
> give me help with that.
>
> Any ideas?
>
> Thanks in advance!
> Jeff
>
> Here's (C#) code that illustrates the problem. I included the return
> values in the comments:
>
> //get the contact I created for this test...
> Microsoft.Office.Interop.Outlook.Application app = new
> Microsoft.Office.Interop.Outlook.Application();
> NameSpace ns = app.GetNamespace("MAPI");
> Microsoft.Office.Interop.Outlook.MAPIFolder folder =
> ns.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
> ContactItem contact = folder.Items[1] as ContactItem;
> MAPIUtils utils = new MAPIUtils();
>
> //define properties...
> int PR_EMS_AB_PROXY_ADDRESSES = unchecked((int)0x800f101e);
> const int g_PR_SMTP_ADDRESS_W = unchecked((int)0x39FE001E);
>
> //analyze the ContactItem
> string emailAddress = contact.Email1Address;//o=Company/ou=First
> Administrative Group/cn=Recipients/cn=0001234
> string emailAddressType = contact.Email1AddressType;//EX
> object contactProp1 = utils.HrGetOneProp(contact.MAPIOBJECT,
> PR_EMS_AB_PROXY_ADDRESSES);//null
> object contactProp2 = utils.HrGetOneProp(contact.MAPIOBJECT,
> g_PR_SMTP_ADDRESS_W);//null
>
> //analyze the AddressEntry
> Redemption.AddressEntry addressEntry =
> utils.GetAddressEntryFromID(contact.EntryID) as
> Redemption.AddressEntry;
> string addressEntryAddress = addressEntry.Address;//null
> object addressEntryProp1 = utils.HrGetOneProp(addressEntry.MAPIOBJECT,
> PR_EMS_AB_PROXY_ADDRESSES);//null
> object addressEntryProp2 = utils.HrGetOneProp(addressEntry.MAPIOBJECT,
> g_PR_SMTP_ADDRESS_W);//null
>


 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      20th Apr 2007
My problem is that I need to discover the SMTP address from the
ContactItem, but all can get is the X.400 address. Is there any way to
get the SMTP address in this case?

Your comment "Just change the contact address to the SMTP version",
implies that I know what the SMTP address is, but I do not. The SMTP
address is the information I'm trying to get via accessing the
ContactItem.

Thanks again!
Jeff

 
Reply With Quote
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      20th Apr 2007
You can use the value of the Email1EntryId property to call
Namespace.GetRecipientFromID, then use any of the applicable tricks to get
the SMTP address from the returned Recipient.AddressEntry object.
If you are using Redemption, you can simply call
RDOSession.GetAddressEntryFromID, then read the RDOAddressEntry.SmtpAddress
property.

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

"Ken Slovak - [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The Exchange address is really only valid for an entry in the GAL. If you
> have a contact that shares that address with the GAL entry then you might
> be able to do what you've done but otherwise it's useless. Just change the
> contact address to the SMTP version and forget about using an X.400
> address for that. The MAPI fields you mention are only there for
> Recipients or AddressEntries that correspond to GAL entries.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "Jeff" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I created a contact in Outlook 2003, then I gave that contact an email
>> address that matches the email address of an Exchange user. When I
>> access this contact using Outlook COM, I now get the Exchange address
>> ("//o=Company/ou=First Administrative Group/cn=Recipients/cn=0001234")
>> instead of the address I typed into the contact ("(E-Mail Removed)").
>>
>> I implemented Ken Slovak's suggestions "To get the SMTP address
>> instead of the Exchange distinguished name", found here (http://
>> groups.google.com/group/microsoft.public.outlook.program_vba/
>> browse_thread/thread/60231601429b1156/811ce165ff5854df?lnk=st&q=outlook
>> +com+get+smtp+email+address+of+contact&rnum=3#811ce165ff5854df)
>>
>> I also implemented Dmitry's instructions "Default SMTP address of an
>> Exchange user" found here (http://www.dimastr.com/redemption/
>> utils.htm)
>>
>> I think those instructions don't apply b/c of the fact that the
>> ContactItem i created isn't really an Exchange user, but merely shares
>> an email address w/ an Exchange user.
>>
>> I know how to get the SMTP addresses from a MailItem, so please don't
>> give me help with that.
>>
>> Any ideas?
>>
>> Thanks in advance!
>> Jeff
>>
>> Here's (C#) code that illustrates the problem. I included the return
>> values in the comments:
>>
>> //get the contact I created for this test...
>> Microsoft.Office.Interop.Outlook.Application app = new
>> Microsoft.Office.Interop.Outlook.Application();
>> NameSpace ns = app.GetNamespace("MAPI");
>> Microsoft.Office.Interop.Outlook.MAPIFolder folder =
>> ns.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
>> ContactItem contact = folder.Items[1] as ContactItem;
>> MAPIUtils utils = new MAPIUtils();
>>
>> //define properties...
>> int PR_EMS_AB_PROXY_ADDRESSES = unchecked((int)0x800f101e);
>> const int g_PR_SMTP_ADDRESS_W = unchecked((int)0x39FE001E);
>>
>> //analyze the ContactItem
>> string emailAddress = contact.Email1Address;//o=Company/ou=First
>> Administrative Group/cn=Recipients/cn=0001234
>> string emailAddressType = contact.Email1AddressType;//EX
>> object contactProp1 = utils.HrGetOneProp(contact.MAPIOBJECT,
>> PR_EMS_AB_PROXY_ADDRESSES);//null
>> object contactProp2 = utils.HrGetOneProp(contact.MAPIOBJECT,
>> g_PR_SMTP_ADDRESS_W);//null
>>
>> //analyze the AddressEntry
>> Redemption.AddressEntry addressEntry =
>> utils.GetAddressEntryFromID(contact.EntryID) as
>> Redemption.AddressEntry;
>> string addressEntryAddress = addressEntry.Address;//null
>> object addressEntryProp1 = utils.HrGetOneProp(addressEntry.MAPIOBJECT,
>> PR_EMS_AB_PROXY_ADDRESSES);//null
>> object addressEntryProp2 = utils.HrGetOneProp(addressEntry.MAPIOBJECT,
>> g_PR_SMTP_ADDRESS_W);//null
>>

>



 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      20th Apr 2007
Email1EntryId is not valid in this case. Passing it into
NameSpace.GetRecipientFromID() throws an exception ("Additional
information: Could not open the item. Try again.").

A visual inspection of Email1EntryId reveals that it's not a binary
string consisting of characters [0...9, A...F], but rather it just
looks like it accessed part of the memory that stores the X500
address. The invalid value is "^\0rey Buda (ABC SS&S)
((E-Mail Removed)".

I inspected this contact in MFC MAPI, and the property 0x804300E1
seems to contain the value I'm looking for,
"(E-Mail Removed)", but I'm afraid to use that unnamed
property that I've never heard of before.

Any other ideas?

Thanks,
Jeff




 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      20th Apr 2007
Here's some values for the contact via OutlookSpy:

Email1EntryID = "^"
Email1Address = "/o=Company/ou=First Administrative Group/
cn=Recipients/cn=0012345;"
Email1AddressType = "EX"
Email1DisplayName = "Jeff Buda (ABC SS&S) ((E-Mail Removed))"


 
Reply With Quote
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      21st Apr 2007
Ouch! Looks like a bug in Outlook... And the same problem exists in Outlook
2007 - it just does not convert the binary data to a hex string.
You can try to read the Email1EntryID property using MAPI, CDO 1.21 or
Redemption (the property is {00062004-0000-0000-C000-000000000046}, 0x8085,
PT_BINARY).
<plug> RDOContact.Email1EntryID along with RDOSession.GetAddressEntryFromID
in Redemption works just fine </plug>

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

"Jeff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Here's some values for the contact via OutlookSpy:
>
> Email1EntryID = "^"
> Email1Address = "/o=Company/ou=First Administrative Group/
> cn=Recipients/cn=0012345;"
> Email1AddressType = "EX"
> Email1DisplayName = "Jeff Buda (ABC SS&S) ((E-Mail Removed))"
>
>



 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      24th Apr 2007
Thanks for the help. I confirmed that your RDO library does get the
SMTP-formatted address that I need. I would like to consider some
other options before I use that work-around.

Regarding your suggestion on reading the property via MAPI, is this
how you would do it via Redemption?

Microsoft.Office.Interop.Outlook.Application app = new
Microsoft.Office.Interop.Outlook.Application();
NameSpace nameSpace = app.GetNamespace("MAPI");
ContactItem contact =
nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Items[1]
as ContactItem;
MAPIUtils mapiUtils = new MAPIUtils();
object result = mapiUtils.GetIDsFromNames(contact.MAPIOBJECT,
"00062004-0000-0000-C000-000000000046", 0x8085, false);


The call to GetIDsFromNames results in this COMException:

Additional information: Error in _HrGetIDsFromNames - CLSIDFromString
0x800401F3


I'm not sure if that error means that I'm using MAPIUtils wrong, or if
Outlook has a bug, as you suggested.

Thanks,
Jeff

 
Reply With Quote
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      24th Apr 2007
That looks fine, you just need to include {} when passing the GUID string:

object result = mapiUtils.GetIDsFromNames(contact.MAPIOBJECT,
"{00062004-0000-0000-C000-000000000046}", 0x8085, false);

Also don't forget to "or" the returned value with PT_BINARY (0x0102). You
can then use MAPIUtils.HrGetOneProp to read that binary prop (variant array
is returned for the binary props), then convert it to a hex string using
MAPIUtils.HrArrayToString


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

"Jeff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks for the help. I confirmed that your RDO library does get the
> SMTP-formatted address that I need. I would like to consider some
> other options before I use that work-around.
>
> Regarding your suggestion on reading the property via MAPI, is this
> how you would do it via Redemption?
>
> Microsoft.Office.Interop.Outlook.Application app = new
> Microsoft.Office.Interop.Outlook.Application();
> NameSpace nameSpace = app.GetNamespace("MAPI");
> ContactItem contact =
> nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Items[1]
> as ContactItem;
> MAPIUtils mapiUtils = new MAPIUtils();
> object result = mapiUtils.GetIDsFromNames(contact.MAPIOBJECT,
> "00062004-0000-0000-C000-000000000046", 0x8085, false);
>
>
> The call to GetIDsFromNames results in this COMException:
>
> Additional information: Error in _HrGetIDsFromNames - CLSIDFromString
> 0x800401F3
>
>
> I'm not sure if that error means that I'm using MAPIUtils wrong, or if
> Outlook has a bug, as you suggested.
>
> Thanks,
> Jeff
>



 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      26th Apr 2007
I did take this issue up w/ Microsoft Support. They are still trying
to determine if this is a bug or not. The support guy said that their
usual workaround for this issue is to use CDO, but they would not
suggest that solution to me as CDO is not supported when working w/
a .Net language as I am.

Their other workaround they tried was to use the
System.DirectoryServices namespace. Basically, parse the X500 address
to find the Exchange user name, then user DirectoryServices to look up
that Exchange user, then use the "proxyaddresses" property to get the
SMTP formatted addresses. However, the support guy could not come up
w/ a DirectorySearcher query string that would work in my environment.

Finally, he suggested that I get the X500 address, parse out the
Exchange user name, put that into a temporary ContactItem, save it,
then parse the email display name which will include SMTP address.
I'll probably do that for the short term, and then next cycle we'll
upgrade to the latest Redemption library and use the RDO method you
described above.

I'll also try getting the property via MAPI, applying your suggested
changes to the code I posted.

Jeff

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading SMTP address from Exchange Sender mail address VebKol Microsoft Outlook VBA Programming 4 6th Mar 2009 04:08 PM
Why do all of my contact email address have SMTP at the end? =?Utf-8?B?QWwgUy4=?= Microsoft Outlook Contacts 1 7th Feb 2006 03:32 PM
SMTP email address in corporate contact list nyugati Microsoft Outlook Discussion 1 4th May 2005 01:26 PM
SMTP Email Address - Exchange 2000 - ASP.NET Tersia Ehlert Microsoft ASP .NET 2 13th Sep 2004 02:51 PM
retrieving Contact SMTP address from Exchange rauschy33 Microsoft Outlook Program Addins 1 11th Dec 2003 08:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:14 PM.