Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending email from outlook, how to get list of "to" addr's from table 1

Status
Not open for further replies.

joshs1100

IS-IT--Management
Jan 24, 2002
23
US
When using DoCmd.SendObject, how can I take a table with a list of email addresses, and use it in the expression to complete the "to" parameter with a semicolon separated list?

Thanks!
 
assuming you emailaddie table is named "YourAddiesTable", and the field in the table containing the address is named "EmailAddress" you could try:

Code:
dim db as DAO.Database
dim rs as DAO.Database
dim strtabname as string
dim strrecipients as string
tabname = "YourAddiesTable"
set db = Application.CurrentDB
set rs = db.OpenRecordset(strtabname)
do until rs.EOF
strrecipients = strrecipients & rs.fields("EmailAddress").value
strrecipients = strrecipients & ";"
loop

just typed, not tested

HTH,
fly

[blue]Typos, that don't affect the functionality of code, will not be corrected.[/blue]

Martin Serra Jr.
 
[red]TYPO[/red]

please replace
Code:
tabname = "YourAddiesTable"

by
Code:
strtabname = "YourAddiesTable"


[blue]Typos, that don't affect the functionality of code, will not be corrected.[/blue]

Martin Serra Jr.
 
Thanks! Was just what I needed.

I had to add the reference for the DAO Library, and added rs.MoveNext to get it to move to the next record in the recordset on the loop.



Code:
Dim db As DAO.database
Dim rs As DAO.Recordset
Dim strtabname As String
Dim strrecipients As String
strtabname = "Your_Table_Name"
Set db = Application.CurrentDb
Set rs = db.OpenRecordset(strtabname)
Do Until rs.EOF
strrecipients = strrecipients & rs.Fields
("Email_Address").Value & ";"

rs.MoveNext

Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top