What language are you working with and what development platform?
You can use CDO 1.21 or Extended MAPI or a MAPI wrapper such as Redemption
for this. CDO is not supported for .NET code and is an optional
installation, Extended MAPI is not supported for .NET code and is C++ or
Delphi only, Redemption and other MAPI wrappers are usable in COM and .NET
languages.
Here's a CDO example using VBA code:
Function GetAccount(sEntryID As String) As String
' EntryID of the email to check
Dim oSession As MAPI.Session
Dim oRecip As MAPI.Recipient
Dim oAE As MAPI.AddressEntry
Dim oMessage As MAPI.Message
Dim oDummy As MAPI.Message
Dim sEmail As String
Const PR_RCVD_REPRESENTING_EMAIL_ADDRESS _
As Long = &H78001E
Const PR_EMAIL As Long = &H3003001E
'usable with piggy-back logon only when Outlook is already running
Set oSession = New MAPI.Session
oSession.Logon "", "", False, False
Set oMessage = oSession.GetMessage(sEntryID)
sEmail = oMessage.Fields(PR_RCVD_REPRESENTING_EMAIL_ADDRESS)
If (Instr(1, sEmail, "/cn", vbTextCompare) >0) Then ' EX address
Set oDummy = oSession.Inbox.Messages.Add("Test subject", _
"Test body")
Set oRecip = oDummy.Recipients.Add("", sEmail)
oRecip.Resolve
If (oDummy.Recipients.Resolved) Then
Set oAE = oRecip.AddressEntry
GetAccount = oAE.Fields(PR_EMAIL)
' in cached EX mode you do not get PR_EMAIL
' in that case you must read PR_EMS_AB_PROXY_ADDRESSES
' at &H800F101E, a multivalued string property. Iterate the
array
' that is returned looking for the one that starts with
"SMTP:" - the
' default SMTP address for that EX recipient.
Else
GetAccount = "" 'failure
End If
Else
GetAccount = sEmail
End If
oSession.Logoff
' now set all objects = Nothing
End Function
Of course the code would be somewhat different for Redemption or Extended
MAPI.