Emails into Access 2003: The receipients email-addresses!

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

Guest

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!
 
Use the Recipients collection of the email. Iterate that and use
Recipient.Address.
 
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!
 
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
 
Back
Top