By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,096 Members | 1,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,096 IT Pros & Developers. It's quick & easy.

MS Access email clients

P: 10
Can anybody tell me how to include my email addresses from a query to the bcc field of a new email.

I created a query to select my email addresses, I tryied using the VBA code below to extract the email addresses and insert them in a SendObject command, but nothing happens. Please Help.

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rcpts As String

Set db = CurrentDb
Set rst = db.OpenRecordset("EmailInfo Clients")
rcpts = ""

With rst
.MoveFirst
Do Until .EOF
rcpts = rcpts & .Fields("Email_Name") & ","
.MoveNext
Loop
End With
DoCmd.SendObject , , , "info@sharpewaygroup.ca", , rcpts, , , True

rst.Close
Mar 27 '07 #1
Share this Question
Share on Google+
5 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Try using a semicolon after the email names instead of a comma.
Expand|Select|Wrap|Line Numbers
  1. Dim db As DAO.Database
  2. Dim rst As DAO.Recordset
  3. Dim rcpts As String
  4.  
  5.    Set db = CurrentDb
  6.    Set rst = db.OpenRecordset("EmailInfo Clients")
  7.    rcpts = ""
  8.  
  9.    With rst
  10.       .MoveFirst
  11.       Do Until .EOF
  12.          rcpts = rcpts & .Fields("Email_Name") & ";"
  13.          .MoveNext
  14.       Loop
  15.    End With
  16.  
  17.    DoCmd.SendObject , , , "info@sharpewaygroup.ca", , rcpts, , , True
  18.  
  19.    rst.Close
  20.  
Mary
Mar 27 '07 #2

P: 10
I tried adding the semi-colon; still nothing

When I debug the code, I get no errors, when I run the command, I get no results and no errors...

What else could I try?
Mar 27 '07 #3

P: 10
In the code that I included in the first thread, Can you tell me if I have enough information in the following code;

Set rst = db.OpenRecordset("EmailInfo_Clients")

The query name that I want to use as the record source is EmailInfo Clients (no underscore), although I've tried this with underscore, no underscore with [ ] and without the [ ]
Mar 27 '07 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
In the code that I included in the first thread, Can you tell me if I have enough information in the following code;

Set rst = db.OpenRecordset("EmailInfo_Clients")

The query name that I want to use as the record source is EmailInfo Clients (no underscore), although I've tried this with underscore, no underscore with [ ] and without the [ ]
Firstly remove the underscore and just leave it as

Expand|Select|Wrap|Line Numbers
  1.  Set rst = db.OpenRecordset("EmailInfo Clients") 
Mar 27 '07 #5

MMcCarthy
Expert Mod 10K+
P: 14,534
Open the immediate window in the VBA editor and add this Debug.Print command as below. See what the printout is in the immediate window.

Expand|Select|Wrap|Line Numbers
  1. Dim db As DAO.Database
  2. Dim rst As DAO.Recordset
  3. Dim rcpts As String
  4.  
  5.    Set db = CurrentDb
  6.    Set rst = db.OpenRecordset("EmailInfo Clients")
  7.    rcpts = ""
  8.  
  9.    With rst
  10.       .MoveFirst
  11.       Do Until .EOF
  12.          rcpts = rcpts & .Fields("Email_Name") & ";"
  13.          .MoveNext
  14.       Loop
  15.    End With
  16. Debug.Print rcpts
  17.  
  18.    DoCmd.SendObject , , , "info@sharpewaygroup.ca", , rcpts, , , True
  19.  
  20.    rst.Close
  21.  
Mary
Mar 27 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.