View Single Post
  #4  
Old April 20th 07, 08:12 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Can't get SMTP address of contact that shares email address of an Exchange user

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]" wrote in message
...
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" wrote in message
ups.com...
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 ").

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#811c e165ff5854df)

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.olFolderConta cts);
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




Ads