Emails into Access 2003: The receipients email-addresses!

A

Anders Berlin

I am importing emails from Outlook 2003 into Access 2003 with Visual Basic.
I have managed to get the Email-address of the sender into Access with:

Rst!From = OlMail.SenderName

However, I would like to have all the receipients email-addresses as well.
Right now I am using:

Rst!To = OlMail.To

But that will NOT give me the email-addresses, only the “names†of the
receipients.

Maybe it has something to do with the fact that there can only 1 sender, but
many receipients.
But I am sure there must be a way to get a all the email-addresses in one
field somehow?

Thanks for any help!
 
K

Ken Slovak - [MVP - Outlook]

Use the Recipients collection of the email. Iterate that and use
Recipient.Address.
 
A

Anders Berlin

I tried:
Rst!ToEmail = OlMail.Recipient.Address
which ofcourse didn't work. I'm sorry but my VB skills are limited. Can you
show me an example?

Thanks for the help!
 
K

Ken Slovak - [MVP - Outlook]

OK, but 2 things to remember about this. First, access to the Recipients
collection has security implications and will fire the security prompts in
secure versions of Outlook since you can harvest email addresses that way.
Second, an email may have more than 1 recipient, which you would have to
deal with.

For information on how to avoid the security prompts see
http://www.outlookcode.com/d/sec.htm

Dim colRecipients As Outlook.Recipients
Dim objRecip As Outlook.Recipient
Dim strAddress As String

Set colRecipients = OlMail.Recipients
For Each objRecip In colRecipients
strAddress = objRecip.Address
'do something with it
Next
 

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