View Single Post
  #2  
Old November 1st 06, 02:58 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,951
Default determining Senders smtp address

Why not just use PR_SENDER_EMAIL_ADDRESS (&HC1F001E) in the Fields
collection of the Message item?

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


"Paul Young" wrote in message
news
I am trying to obtain the smtp address of a message selected by our
Servicedesk staff using the code:

Set objOutlook = CreateObject("Outlook.Application")
Set objActiveExplorer = objOutlook.ActiveExplorer
Set objInboxEmail = objActiveExplorer.Selection(1)
strSender = objInboxEmail.SenderEmailAddress

This returns the smtp address for internet messages but the distinguished
name of exchange users.

I've found code to get the smtp address for a message using CdoPR_EMAIL
value.

Public Const CdoPR_EMAIL = &H39FE001E

Set objSession = CreateObject("MAPI.Session")
objSession.Logon "", "", False, False, 0
' Get first message from inbox
Set objFolder = objSession.Inbox
Set objMessages = objFolder.Messages
Set objMessage = objMessages.GetLast()

' Get address
Set objAddressEntry = objMessage.Sender
strEMailAddress = objAddressEntry.Address

' Check if it is an Exchange object
If Left(strEMailAddress, 3) = "/o=" Then

' Get the SMTP address
strAddressEntryID = objAddressEntry.ID
strEMailAddress =
objSession.GetAddressEntry(strAddressEntryID).Fiel ds(CdoPR_EMAIL).Value
End If

MsgBox strEMailAddress

My problem is that I can't get this to work with the above code. Are the
message items different in each piece of code? How do you access the
.Sender
property from objInboxEmail?

Thanks for any help.



Ads
 

Credit Cards - Western Union Money Order - Blogs Forum - Debt Consolidation - Best Credit Card Deals