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

Automate Email out of Access

Status
Not open for further replies.

mattner

Technical User
Oct 16, 2003
13
US
I am trying to build a macro in order to send a custom email to multiple people out of a single table. The email will have a list of the individuals buying habits so some individuals might have 4 lines and others will have 10 lines. The Sendobject function does not seem to have this ability. Any ideas?
 
I am not sure how to do this with a macro, but it would be very easy with code. Is code an option?
 
Code might be an option. How would you go about doing it?
 
The code would look something like:
Code:
Private Sub cmdEmailAll_Click()
Dim rs As DAO.Recordset
'Change the italics to the right names

'tblPersons = name of table
Set rs = CurrentDb.OpenRecordset("[i]tblPersons[/i]")

Do While Not rs.EOF
   strMessage = ""
   'Message to send. 
   strMessage = "Dear " & rs![i]Surname[/i] & vbCrLf _
      & rs![i]BuyingHabits[/i] & vbCrLf

   'SendObject with preview
   DoCmd.SendObject acSendNoObject, , , rs![i]EmailAddress[/i], , , "Re: Habits", strMessage, True
   rs.MoveNext
Loop
End Sub
You would probably have this run in the click event of a button. If Buying Habits are a separate table, a little more code would be needed. What you have above is a very rough outline.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top