email automaticly

L

Luis Marques

I have a table in Access that contains the recipients name, email address.
Does anybody know how to send an automatic email after the
user clicks a command button in a form?
 
D

Dorian

It depends on what email program your users use?
With Outlook, you have to create an Outllook object and then use the various
properties and methods of Outlook.
You also have to deal with the Microsoft eOutlook security prompt.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
R

ryguy7272

This is what I use:
Option Compare Database

Private Sub cmdMail_Click()
On Error GoTo Err_cmdMailTicket_Click


Dim varTo As Variant '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim RecDate As Variant '-- Rec date for e-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim strSQL As String '-- Create SQL update statement
Dim stWho As String '-- Reference to tblUsers
Dim errLoop As Error
Dim strFirstName As String

'-- Combo of names to assign ticket to
stWho = Me.cboAssignee
stWhere = "tblUsers.strUserID = " & "'" & stWho & "'"
'-- Looks up email address from TblUsers
varTo = DLookup("[strEMail]", "tblUsers", stWhere)

stText = ", please see the attachment." & Chr$(13) & Chr$(13) & _
"Thanks," & RecDate & Chr$(13) & Chr$(13) & _
"Ryan---"

'Write the e-mail content for sending to assignee
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1

On Error GoTo Err_Execute
CurrentDb.Execute strSQL, dbFailOnError
On Error GoTo 0

Exit Sub

Err_Execute:

Resume Next

Exit_cmdMailTicket_Click:
Exit Sub

Err_cmdMailTicket_Click:
MsgBox Err.Description
Resume Exit_cmdMailTicket_Click

End Sub


I also have a ComboBox connected to a bit of SQL:
SELECT tblUsers.strUserID
FROM tblUsers;

That points to the RowSource in the Properties of the ComboBox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top