Could somebody have a look at the below code, can only get the code to email one customer, also is thee a way of forcing outlook to use a email address that you specify instead of grabbing the default sending address.
Private Sub Email_Click()
Dim db As Database
Dim rs As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Email FROM Cust")
Do Until rs.EOF
On Error GoTo ErrorHandler
With objEmail
.To = rs!Email
.Subject = "Appointment Required "
.HTMLBody = "The system we installed at your premises is due for a service please can<br>you contact us to arrange a suitable time<br><br>"
.Send
End With
ErrorHandler:
Resume Next
rs.MoveNext
Loop
End Sub
Private Sub Email_Click()
Dim db As Database
Dim rs As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Email FROM Cust")
Do Until rs.EOF
On Error GoTo ErrorHandler
With objEmail
.To = rs!Email
.Subject = "Appointment Required "
.HTMLBody = "The system we installed at your premises is due for a service please can<br>you contact us to arrange a suitable time<br><br>"
.Send
End With
ErrorHandler:
Resume Next
rs.MoveNext
Loop
End Sub