Email Macro?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table set up like this:
FirstName - LastName - EmailAddress - TakenClass? (yes/no type)

I have a query that searches for all records where TakenClass? = yes

I am trying to send an email to each person where TakenClass? = yes.

I set up a Data Access Page to look like the body of the email that I want
to send. The beginning of the body of the email should say "To: "+FirstName.
I want to send out the page to everyone whose taken the class (automatically
getting the email address from the EmailAddress column) and I want to
automatically fill in the first name.

Can I create a macro that does this? If not, how can I implement this?
 
My code runs from a "Send Email" button which sits next to a text box that
displays the person's Email address. It can be modified to send batch emails.
To work, the Outlook mail client (we use Outlook) must have the 'Automatic
Name Checking' option box unchecked.

Private Sub cmdCEmail_Click()

'This routine checks to ensure there is text in the
'email address field. It sends the Email through the Outlook
'mail client. In Outlook, the box "Automatic Name Checking"
'must not be checked.

On Error GoTo error_handler

If txtCEmail = "" Or IsNull(txtCEmail) Then
MsgBox "Please enter an Email address", vbOKOnly, "Need Address"
Exit Sub
End If

DoCmd.SendObject , , , Me![txtCEmail]

error_handler_exit:
Exit Sub

error_handler:
MsgBox "Email cancelled", vbOKOnly, "Cancellation"
Resume error_handler_exit

End Sub
 
Back
Top