
SMTP address vs. Exchange address (simple, I hope)
Try the following code which requires the installation of Redemption from
http://www.dimastr.com/redemption
Function R_GetSenderAddress(objSMail As SafeMailItem)
Dim strType As String
Dim bytID() As Byte
Dim strID As String
Dim objSAE As Redemption.AddressEntry
Dim objUtils As New Redemption.MAPIUtils
Const PR_SENDER_EMAIL_ADDRESS = &HC1F001E
Const PR_SENDER_ADDRTYPE = &HC1E001E
Const PR_SENDER_ENTRYID = &HC190102
Const PR_EMAIL = &H39FE001E
strType = objSMail.Fields(PR_SENDER_ADDRTYPE)
If strType = "SMTP" Then
R_GetSenderAddress = objSMail.Fields(PR_SENDER_EMAIL_ADDRESS)
ElseIf strType = "EX" Then
bytID() = objSMail.Fields(PR_SENDER_ENTRYID)
strID = ByteIDToStr(bytID)
Set objSAE = objUtils.GetAddressEntryFromID(strID)
R_GetSenderAddress = objSAE.Fields(PR_EMAIL)
End If
End Function
Function ByteIDToStr(MyBytes() As Byte)
Dim strID As String
Dim i As Integer
Dim intByte As Integer
For i = LBound(MyBytes) To UBound(MyBytes)
intByte = MyBytes(i)
If intByte < 16 Then
strID = strID & "0" & Hex(intByte)
Else
strID = strID & Hex(intByte)
End If
Next
ByteIDToStr = strID
End Function
--
Randy Byrne, MVP - Outlook
http://www.microeye.com
Building Applications with Microsoft Outlook 2002 (MSPress - July 2001)
Building Applications with Microsoft Outlook 2000 (MSPress)
http://www.microeye.com/books
Micro Eye ZipOut 2000
http://www.microeye.com/zipout
Yes I did define this as... Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E
Unfortunately, the code doesn't return a thing. Can this only be used when
using the address book?
-Spencer
Quote:
> And I'm assuming you have defined or got the definition for the proxy
> address constant somewhere. Do you get any addresses in the proxy address
> for the user? The X.400 address should appear there as well.
> Tom
> --
> Looking for a good book on developing using ADSI, Outlook 2000 and
Exchange
> 5.5/2000? Check out:
> http://www.amazon.com/exec/obidos/ASIN/0735610193/
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
> reserved.
> > Greetings All.
> > When I loop through the recipients of an mailitem object looking for the
> > email address, I sometimes get an address that looks like this: "/O=MY
> > COMPANY ./OU=MYLAN/CN=RECIPIENTS/CN=spencerw" These are for people
setup
> in
> > our Global Address book. I need to obtain SMTP address programatically.
> > I tried the following without any luck:
> > Function GetOtherAddress(objMsg As Outlook.MailItem, sName)
> > Dim objSession As MAPI.Session
> > Dim objCDOMsg As MAPI.Message
> > Dim objRecip As MAPI.Recipient
> > Dim objField As MAPI.Field
> > Dim v
> > Dim sSMTP As String
> > Dim strEntryID As String
> > Dim strStoreID As String
> > Dim strAddress As String
> > ' start CDO session
> > Set objSession = CreateObject("MAPI.Session")
> > objSession.Logon , , False, False
> > ' pass message to CDO
> > strEntryID = objMsg.EntryID
> > strStoreID = objMsg.Parent.StoreID
> > Set objCDOMsg = objSession.GetMessage(strEntryID, strStoreID)
> > On Error Resume Next
> > For Each objRecip In objCDOMsg.Recipients
> > Debug.Print objRecip.Name
> > If objRecip.Name = sName Then
> > objRecip.AddressEntry.Fields
> (CdoPR_EMS_AB_PROXY_ADDRESSES)
> > For Each v In objField.Value
> > Debug.Print v
> > If LCase(Left(v, 4)) = "smtp" Then
> > MsgBox "Foreign System Address: " & v
> > sSMTP = v
> > Exit For
> > End If
> > Next v
> > End If
> > Next objRecip
> > GetOtherAddress = sSMTP
> > On Error GoTo 0
> > Set objField = Nothing
> > Set objRecip = Nothing
> > Set objCDOMsg = Nothing
> > objSession.Logoff
> > Set objSession = Nothing
> > End Function
> > Any ideas?
> > -Spencer