Can I create Outlook Distribution List from Access database?

J

Jan Main

Is it possible to create a Distribution List from email addresses already
stored in an Access database.
I can send an email to each individual email address listed in the database,
but would like to send the same email to several of the email addresses in
one go.
 
S

Sue Mosher [MVP]

You don't need (and shouldn't bother with) a distribution list for that.
This can be done with Outlook VBA code that creates a message (CreateItem
method) and sets the To property of the message to a semi-colon delimited
string of the desired addresses.

Note, though, that this means each recipient will see the others' addresses,
which might not be desirable for privacy reasons. Your existing technique,
which I presume is mail merge, might be better for that reason (and because
it requires no code.

Please post follow-up any questions or comments to the forum at
http://social.answers.microsoft.com/Forums/en-US/outlooksend/threads as this
newsgroup will be discontinued any day now.
 
Joined
Feb 23, 2011
Messages
1
Reaction score
0
Is it possible to create a Distribution List from email addresses already
stored in an Access database.
I can send an email to each individual email address listed in the database,
but would like to send the same email to several of the email addresses in
one go.


Here is the code I used to read rows from a table to make an email list.
You will need a table with email addresses with 1 row for each person.
It should have the full email address.
You will need to write a query against the table such as: select * from ……





Public Sub eMailDistro()
DoCmd.SetWarnings False
'**********************************************************

Dim strConn As String
Dim myQueryDef As QueryDef
Dim rst As Recordset
Dim oOApp_001 As Outlook.Application
Dim oOApp_001_B As Outlook.Application
Dim oOMail_001 As Outlook.MailItem
Dim conn As ADODB.Connection
Dim eTotal As Long
Dim distro As String

Set oOApp_001 = CreateObject("Outlook.Application")
Set oOMail_001 = oOApp_001.CreateItem(olMailItem)

'q below just calls all recs from table with emails
Set myQueryDef = CurrentDb.QueryDefs("yourquerywithtablewithemailsl")
Set rst = myQueryDef.OpenRecordset(, dbOpenDynaset)


'This DCOUNT will count the number of records and put it in eTotal
eTotal = DCount("yourfieldwithemailaddresses", "yourtablewithemailaddresssl")

'Sets the email distro to blank
distro = ""

'Starts a for loop for the number of email addresses in the table
For i = 1 To eTotal
'concats each name together with ;
distro = distro & ";" & rst.Fields("yourfieldwithemailaddress")
'In the loop, need to move to the next record to concat email address
'If trys to move pass last rec, then cause error, so checked for last rec before moving
If i <> eTotal Then
rst.MoveNext
End If


Next i



With oOMail_001
‘now use the variable disto with all the email names in the to field of outlook
.To = distro
.Body = "Please find attached."

Etc……………….
 

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