Private Sub button_email_Click()
Dim db As Database
Dim rs As Recordset
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
dim strBody as string
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set db = CurrentDb
Set rs = CurrentDb.OpenRecordset("qryEmail_IRs")
rs.movefirst
do until rs.eof
strBody=strBody & rs!TripID & " " & rs!Booker & vbcrlf
rs.movenext
loop
Recipient = "[email protected]"
With MailOutLook
.To = Recipient
.Subject = "Incident Report"
.Body = strBody
.DeleteAfterSubmit = True
.Send
End With
Set MailOutLook = Nothing
Set appOutLook = Nothing
Exit Sub
End Sub
Open in New WindowSelect All
|