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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to automate Emails to more than One User with DoCmd.SendObject ? 1

Status
Not open for further replies.

waldemar

Programmer
Nov 15, 2001
245
DE
When I use this code, an Outlook Message Window appears, fills in some Address stuff and leaves it to the user to add text and eventually press SEND:

DoCmd.SendObject , , acFormatRTF, Me.strEmail.Value, , , "Email Subject", "", True

What can I do to provoke some kind of Mass Mailing (Automating the SEND-Button?)? Is it possible to DoCmd.SendObject without any further User Action? To send several seperated Emails with one Click? (Not using the CC or BCC fields and ONE Email)

 


You could put the docmd.sendobject command inside some looping code where you are reading a set of records with individual email addresses in them and sending the same email to each individually.

Example: You have a table called tblCustomers with a field called EmailAddress text(50). Create a query that will select the Customers that you want to send an email to and call it qryCustomers. Include any information needed for the Email like Name, EmailAddress, etc.

On a form you have a button that when clicked executes the following code:

Dim db as DAO.database
Dim rs as DAO.recordset
Dim vEmailMessage as string
Dim vEmailAddress as string
Set db = currentdb
Set rs = db.OpenRecordset("qryCustomers", dbOpenDynaset)
rs.movefirst
Do
vEmailAddress = rs("EmailAddress")
DoCmd.SendObject , , acFormatRTF, vEmailAddress, , , "Email Subject", "", False
rs.movenext
Loop until rs.eof

This code will select the records from the table tblCustomers for each record selected send an individual email to them using the EmailAddress in the record without the user having to perform any other function. The final parameter that you had set to True should be set to false to allow for the email to be sent without editing. Here is the ACCESS description of that parameter:

editmessage Use True (–1) to open the electronic mail application immediately with the message loaded, so the message can be edited. Use False (0) to send the message without editing it. If you leave this argument blank, the default (True) is assumed.

Let me know how this works for you.



Bob Scriver
 
Ahhh Cheers Bob..... the last False Parameter was what I was looking for... Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top