A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

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



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 20th 07, 06:26 PM posted to microsoft.public.outlook.program_vba
Jeff
external usenet poster
 
Posts: 41
Default Can't get SMTP address of contact that shares email address of an Exchange user

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
  #2  
Old April 20th 07, 07:06 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Can't get SMTP address of contact that shares email address of an Exchange user

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


  #3  
Old April 20th 07, 07:33 PM posted to microsoft.public.outlook.program_vba
Jeff
external usenet poster
 
Posts: 41
Default Can't get SMTP address of contact that shares email address of an Exchange user

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

  #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




  #5  
Old April 20th 07, 09:51 PM posted to microsoft.public.outlook.program_vba
Jeff
external usenet poster
 
Posts: 41
Default Can't get SMTP address of contact that shares email address of an Exchange user

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)
".

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

Any other ideas?

Thanks,
Jeff




  #6  
Old April 20th 07, 10:23 PM posted to microsoft.public.outlook.program_vba
Jeff
external usenet poster
 
Posts: 41
Default Can't get SMTP address of contact that shares email address of an Exchange user

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) )"


  #7  
Old April 21st 07, 07:39 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

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




  #8  
Old April 24th 07, 09:54 PM posted to microsoft.public.outlook.program_vba
Jeff
external usenet poster
 
Posts: 41
Default Can't get SMTP address of contact that shares email address of an Exchange user

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.olFold erContacts).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

  #9  
Old April 24th 07, 10:47 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

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



  #10  
Old April 26th 07, 03:43 PM posted to microsoft.public.outlook.program_vba
Jeff
external usenet poster
 
Posts: 41
Default Can't get SMTP address of contact that shares email address of an Exchange user

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

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Redemption and hiding user in exchange from address lists [email protected] Outlook and VBA 8 August 7th 06 06:53 PM
SMTP Rejected email address FyrFtrEmt Outlook Express 4 June 18th 06 11:10 PM
How to determine what SMTP address email was sent to? BCole8888 Outlook - General Queries 3 February 8th 06 03:08 PM
Why do all of my contact email address have SMTP at the end? Al S. Outlook - Using Contacts 1 February 7th 06 03:32 PM
Set which local email account can send mail to contacts in address book. (associating an email address with a contact) Scott Streit Outlook - General Queries 3 January 27th 06 02:57 PM


All times are GMT +1. The time now is 07:51 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.