Now that my first question was answered I move on to the next.
I have this code to send an email
Works great.
Now my issue is that I need to send this to all the contacts in a table.
Table name is EmailTest, Field name is email. Enter the email address from the field name into the .To = line
hope this makes sense?
I have this code to send an email
Code:
Private Sub Request_Click()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
On Error Resume Next
With OutMail
.Body = "There is a Transport available on," & vbNewLine & Me.TBtransportdate.Value & " at " & Me.TBtransporttime.Value _
& " for " & Me.TBDuration.Value & " Hours." & vbNewLine & "If you are available for this transport please reply." & vbNewLine _
& "Transport # " & Me.TBID.Value & vbNewLine & "In your reply please enter your name and the number of the Transport." _
& vbNewLine & "Transports will be awarded in the order of those that respond."
.Subject = "Available Transport"
.To = emailaddress
.SendUsingAccount = OutApp.Session.Accounts.Item(2)
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
DoCmd.Close
End Sub
Works great.
Now my issue is that I need to send this to all the contacts in a table.
Table name is EmailTest, Field name is email. Enter the email address from the field name into the .To = line
hope this makes sense?