P
Paul Young
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).Fields(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.
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).Fields(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.