Problem with Sent Items/Redemption

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

I am using the Redemption library to find the SenderEmailAddress of a mail.
It works fine in Inbox, but I want something else:
for an item in Sent Items I wand the "To" property to give me an email
address, but I am getting only a name. How do I get the proprty "To", like I
get SenderEmailAddress in Inbox?

Thanks,
Yonina.
 
PR_DISPLAY_TO (0x0E04001E) is a name field. To get the actual email address
you would need to access the Recipients collection of the email item and use
the PR_EMAIL_ADDRESS (0x3003001E) field.
 
How would I do that?
I tried code from outlookcode, but it didn't help.
Maybe you can give me a code sample or a site that has a code sample?

here is what I tried:

Dim folderName As String
folderName = Application.ActiveExplorer.CurrentFolder

Set ol = GetObject(, "OUTLOOK.APPLICATION")
Set MAPI = ol.GetNamespace("MAPI")

Set rmafolder = MAPI.folders("Mailbox - Ayelet")

If folderName = "Inbox" Then
Set Folder = rmafolder.folders("Inbox")
act = "In"
Else
If folderName = "Sent Items" Then
Set Folder = rmafolder.folders("Sent Items")
act = "Out"
Else
GoTo Err
End If
End If


For Each mail In Folder.Items
If mail.Body = strEmail Then
Set objSession = CreateObject("MAPI.Session")
objSession.Logon "", "", False, False

' pass message to CDO
strEntryID = mail.EntryID
strStoreID = mail.Parent.StoreID
Set objCDOMsg = objSession.GetMessage(strEntryID,
strStoreID)
If act = "In" Then
Set objSession = CreateObject("MAPI.Session")
objSession.Logon "", "", False, False

' pass message to CDO
strEntryID = mail.EntryID
strStoreID = mail.Parent.StoreID
Set objCDOMsg = objSession.GetMessage(strEntryID,
strStoreID)

' get sender address
On Error Resume Next
strAddress = objCDOMsg.Sender.Address
If Err = &H80070005 Then
'handle possible security patch error
MsgBox "The Outlook E-mail and CDO Security Patches
are " & _
"apparently installed on this machine. " & _
"You must response Yes to the prompt about " & _
"accessing e-mail addresses if you want to " & _
"get the From address.", vbExclamation, _
"GetFromAddress"
End If

GetFromAddress = strAddress

Set objCDOMsg = Nothing
objSession.Logoff
Set objSession = Nothing
MsgBox (mail.SenderEmailAddress)
adrs = mail.SenderEmailAddress
GoTo aaa
Else
If act = "Out" Then
Set objReply = objCDOMsg.Reply
On Error Resume Next
Set objRecip = objReply.Recipients.Item(1)
strAddress = objRecip.Address
If strAddress = "" Then
strAddress = objRecip.Name
End If
ElseIf Err = 287 Then
'handle possible security patch error
strAddress = ""
MsgBox "The Outlook E-mail Security Patch is " & _
"apparently installed on this machine. " & _
"You must response Yes to the prompt about " & _
"accessing e-mail addresses if you want to " & _
"get the Reply To address.", vbExclamation, _
"GetReplyToAddress"
End If

GetReplyToAddress = strAddress
MsgBox strAddress

Set objRecip = Nothing
Set objReply = Nothing

GoTo aaa
End If
End If
'how to get actual email address
End If
Next
 
Loop through all the items in the Recipients collection and for each
recipient check that the Type property = olTo. If true, read the
Recipient.Address property.

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

this is the code I tried:
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.Application.ActiveExplorer.Selection(1)
Set myrecipient = myItem.Recipients.Address
MsgBox myrecipient

and this is the error I get:
error number: 438
description: Object doesn't support this property or method

please! I need help!
 
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.Application.ActiveExplorer.Selection(1)
MyRecipientAddress = myItem.Recipients(1).Address
MsgBox MyRecipientAddress

or to show every recipient:

For Each oRecipient in myItem.Recipients
MsgBox oRecipient.Address
Next
 
THANK YOU!!!

EXACTLY WHAT I NEEDED!!!

:)

Ken Slovak - said:
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.Application.ActiveExplorer.Selection(1)
MyRecipientAddress = myItem.Recipients(1).Address
MsgBox MyRecipientAddress

or to show every recipient:

For Each oRecipient in myItem.Recipients
MsgBox oRecipient.Address
Next
 
Is there any way to avoid the message:
A program is trying to access e-mail addresses you have stored in Outlook.
Do you want to allow this?
 
Yes, use Redemption. Read access to the email addresses is restricted as an
email address harvesting precaution. If you use Redemption objects for the
Recipient objects you won't get the security prompts.
 
Back
Top