Address of people I sent mail to

G

Guest

Hi!

I have a problem I am working on for a long time with no success.
In a userform I wrote code in VBA to read a current email body and send it
to a table in access.
Everything works fine. The only problem is when I read the address:
in Inbox: the address "To" ("From" I was able to read)
in Sent Items: the address "From" ("To" I was able to read)

I usually use the mailItem.To and mailItem.SenderEmailAddress and they work,
but if there is a name of a customer instead of the address, I get the name!
(and I need the address!)
I searched in outlookcode site and checked many code examples, but as I
said, no success.

Please, can anyone help???

Thanks,
Yonina.
 
G

Guest

Basically, you use the SenderName and SenderEmailAddress properties to access
information on the sender, and use the Recipients collection to return the
Address and Name properties for who the message was sent to.

SMTP addresses are always in address type properties, and should never be a
person name.

Can you show your code please?
 
G

Guest

OK.
This is the code I am using:

Dim folderName As String
folderName = Application.ActiveExplorer.CurrentFolder

If folderName = "Inbox" Then
adrs = Application.ActiveExplorer.Selection(1).SenderEmailAddress
Else
If folderName = "Sent Items" Then
adrs = Application.ActiveExplorer.Selection(1).To
Else
GoTo Err
End If
End If


As I said, if I have a name of my customer instead of the address, "adrs"
doesn't get the address. It gets the name of my customer.
I read alot about CDO etc. but every time I try to use a code sample I find
it never works :(

Maybe you can give me an example that works?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top