Send Bulk Email Thru Outlook from Access

Mmccl

Enough to be Scary
Local time
Today, 12:01
Joined
Nov 26, 2003
Messages
43
I have VBA code on an Access Form that will allow me to send an email messge thru Outlook Express to the email address in a field, but is there a way, using a modification of the same code to Send Bulk email to every email address in that field in my database Using a Query?

I can get the code to read an email address in a single field from a form, but could I have it retrieve all email addresses from a query? I want the email addresses to appear ready to send from MS Outlook Express in the Bcc: field to everyone in my Database.

Form so far:

Feild which contains email address.
On click button that opens Outlook express and places email address in the To: CC: or Bcc: line (based on code).

code i have got so far:
______________________________________
Private Sub Email2_Click()
DoCmd.SendObject _
, _
, _
, _
("" & Me!EmailAddress), _
, _
, _
, _
, _
True
End Sub
_______________________________________
Private Sub Form_frm_Missions_Main2()
Me!Email2.Enabled = Not (IsNull(Me!EmailAddress))
End Sub
_______________________________________

Can anyone help
 
Last edited:
You'll need to use DAO or ADODB to get the result you want. I don't have the time to go into full detail right now so...

Try searching for the posts of BukHix and Hayley Baxter as they constantly have email solutions such as this.
 
looking at all the threads - thanks

Habeas corpus

Thanks for the response. Looking at all the threads on this subject.

I was unable to find these threads until you gave me names. My topic searches turn up very little (mostly me).

This will keep me busy for a while.

Mike
 
The direct approach

Still would like the direct approach if anyone has a simple answer or a download that shows the solution to this
 
Basically:

Code:
Dim db As DAO.Database
Dim rs As DAO.Recordet
Dim strEmail As String

Set db = CurrentDb
Set rs = db.OpenRecordset("MyQuery")

With rs
    Do While Not .EOF
        strEmail = strEmail & .Fields("MyEmailField") & ";"
        .MoveNext
    Loop
    .Close
End With

strEmail = Left(strEmail, Len(strEmail) - 1)

DoCmd.SendObject.....
 
Compile Error

Still not fully understanding the Loop idea. This is the code I attached to the cmdbutton, but when run i got

compile error:
User-defined type not defined

on the first line. Clearly I'm not doing something right.

________________________________
Private Sub Email2_Click()

DIM db As DAO.Datebase
Dim rs As DAO.Recordet
Dim strEmail As String

Set db = CurrentDb
Set rs = db.OpenRecordset("qryEmailAddress")

With rs
Do While Not .EOF
strEmail = strEmail & .Fields("PrimaryEmailAddress") & ";"
.MoveNext
Loop
.Close
End With

strEmail = Left(strEmail, Len(strEmail) - 1)

DoCmd.SendObject _
, _
, _
, _
("" & Me!PrimaryEmailAddress), _
, _
, _
, _
, _
True

End Sub
_________________________________


My Database file is named: Missions Contact Manager.mdb
The Table the data is in: tbl Partners
The query that gets the email addresses: qryEmailAddress
The form that contains the command button: frm Missions Main
(all spaces are as they appear)

More or less at a loss to understand this. Very new here. My "programing skills" (for lack of a better phrase) were cut in Q&A back 15 years ago.

Thanks Michael
 
The error you are getting would imply that you are using Access 2000 or Access 2000.

DAO (Data Access Objects) was the data accessing method in Access 97 which has since been upgraded to ADO (ActiveX Data Objects).

You can either change the code to ADO:

Code:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strEmail As String

Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset

rs.Open "MyQuery", cn

With rs
    Do While Not .EOF
        strEmail = strEmail & .Fields("MyEmailField") & ";"
        .MoveNext
    Loop
    .Close
End With

strEmail = Left(strEmail, Len(strEmail) - 1)

DoCmd.SendObject.....


or, set a reference to DAO:

open a module;
goto Tools -> References;
check the box for Microsoft Data Access Objects 3.6 Library
move its priority above Microsoft ActiveX Data Objects
 
Last edited:
Hangs on recordset

now it's hanging on the second line of code

Dim rs As ADODB.Recordet

I set it up like this:
 
I think that's the ticket. I'm in the testing phase now. but it worked on my sample data.

With Post above got out ahead of myself. Disregard.

Sorry I did not disclose the Access Version earlier.

Mike
 
Seems to all check out

This code is perfect. Simple yet effective. All tests on sample data check out.

One final thought. Is there a limit to the number of email address that could be "sent" to Outlook Express. I have a total of about 400 in my database and I want to send to all of them at once ie. with one newsletter mail.

Thanks for the Help
Michael
 

Users who are viewing this thread

Back
Top Bottom