How to get SMTP address from Distinguished Name

A

asma.alam

I can get the SMTP address of the current user using CDO but I need to
loop through all the names in the TO list of an incoming message and
get all their SMTP addresses as well. I guess I would need to change
the current user each time, get their AddressEntry.ID and then extract
the Cdo_PR_EMAIL field. But how can I do this. Also I dont want to be
prompted by any security dialogs as my processes have to run without
human intervention

Thanks
 
D

Dmitry Streblechenko

For each recipient, read the Recipient.AddressEntry property, then use
AddressEntry.Fields to read the PR_SMTP_ADDRESS property (0x39FE001E)

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

Austin Stephens

Sue,

In C# I use the following to resolve:

MailItem mailTemp = item.ReplyAll();

Is this eventually going to cause me problems? I’m in early beta now.

Thanks...
Austin
 
S

Sue Mosher [MVP-Outlook]

Most likely, yes:

1) You'll still get the DN not the SMTP address.

2) Unless this is a COM addin for Outlook 2003 or for trusting at the
Exchange server level, you'll get security prompts.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
A

asma.alam

Thanks Dimitry and Sue for that quick response. I can now get the SMTP
addresses of all in the TO list using Redemption. However I still get
the Outlook security prompt dialog.

Presumably this happens when I detect the incoming objMsg As
Outlook.MailItem and the code runs to convert it to a CDO message using

objCDOMsg = objSession.GetMessage(strEntryID, strStoreID)
before passing it onto the Redemption routines.
How can I avoid such prompts? I cant have user interventions in my
process.


And secondly Can you please tell me how to change the following code to
use the name of a person OTHER than the CurrentUser. It works fine to
return the SMTP address of the CurrentUser so I was trying to use it
return other users Smtp addresses, by somehow trying to impersonate
another user but I'm not really sure how.

Set objSession = CreateObject("MAPI.Session")
objSession.Logon "", "", False, False
Set objAddressEntry = objSession.CurrentUser
strAddressEntryID = objAddressEntry.ID
' Get the SMTP address
strEMailAddress =
objSession.GetAddressEntry(strAddressEntryID).Fields(CdoPR_EMAIL)

thanks again
Asma
 
D

Dmitry Streblechenko

1. No, Session.GetMessage does not display a prompt, so it must be something
else.
2. Where does the other address entry come from? If you only know the name,
use Namespace.CreateRecipients or Namespace.AddressLists to drill down to a
particular address list and find an entry in its contents table.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top