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

Email code??

Status
Not open for further replies.

mike1975

IS-IT--Management
Jun 26, 2001
38
0
0
GB
Can anyone supply with me some code that will enable me to send an email to a supplier when the suppliers email is held in a supplier table - Basically i want to put in the supplier code in the orders table - hit a button and the data shown on the form will be sent to that supplier.
 
You may find this helpfull as a start.
The qryElectronicCopiesOfPublication is a make table query that produces a table of only those on the database that have a valid email address. It creats 3 fields, the first is the email address and the others are the subject and body which it gets from text boxes on a form. I also have some other filters on the form to select recipients from various categories so that each category may receive different subject and body text.
Let me know if you need more.
Cheers
Norm

Private Sub SendElectronicVersion_Click()
Dim Response As Integer

Response = MsgBox("Are you sure you wish to send these E-MAILS?", vbQuestion + vbYesNo, "Confirmation")
If Response = vbYes Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryElectronicCopiesOfPublication"
DoCmd.SetWarnings True
Dim dbs As Database
Dim rst As Recordset
Dim Receiver As String
Dim Subject As String
Dim Body As String
Dim Counter As Integer
Dim VrecordCount As Integer
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblElectronicCopiesOfPublication")
Counter = 1
VrecordCount = rst.RecordCount

rst.MoveFirst

Do While Counter < VrecordCount ' Check for end of file.
Receiver = rst.Fields(0)
Subject = rst.Fields(1)
Body = rst.Fields(2)

Debug.Print Receiver, Subject, Body
DoCmd.SendObject acSendNoObject, , , Receiver, , , Subject, Body, 0
rst.MoveNext
Counter = Counter + 1
Loop
rst.Close
Set dbs = Nothing
Else
End If


End Sub
 
Look at the following:

DoCmd.Sendobject

After typing this you will get the usual droplist of settings. From here you can specify field names, or values, and you can even set it to allow you to edit the email before sending it.

Andrew.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top