Check that at least one contact has been selected.
If lst.ItemsSelected.Count = 0 Then
MsgBox “Please select at least one contact”
lst.SetFocus
GoTo ErrorHandlerExit
End IfTest for required fields.
strSubject = Me![txtSubject].Value
If strSubject = “” Then
MsgBox “Please enter a subject”
Me![txtSubject].SetFocus
GoTo ErrorHandlerExit
End IfstrBody = Me![txtBody].Value
If strBody = “” Then
MsgBox “Please enter a message body”
Me![txtBody].SetFocus
GoTo ErrorHandlerExit
End IfFor Each varItem In lst.ItemsSelectedCheck for email address.
strEMailRecipient = Nz(lst.Column(1, varItem))
Debug.Print “EMail address: “ & strEMailRecipient
If strEMailRecipient = “” Then
GoTo NextContact
End IfstrJobFile = Nz(Me![txtJobFile])Create a new mail message with the job file attachment and send to contact.
Set appOutlook = GetObject(, “Outlook.Application”)
Set msg = appOutlook.CreateItem(olMailItem)
With msg
.To = strEMailRecipient
.Subject = strSubject
.Body = strBody
If strJobFile <> “” Then
.Attachments.Add strJobFile
End If
.Display
End WithWorking with External Data 10