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 If
Test for required fields.
strSubject = Me![txtSubject].Value
If strSubject = “” Then
MsgBox “Please enter a subject”
Me![txtSubject].SetFocus
GoTo ErrorHandlerExit
End If
strBody = Me![txtBody].Value
If strBody = “” Then
MsgBox “Please enter a message body”
Me![txtBody].SetFocus
GoTo ErrorHandlerExit
End If
For Each varItem In lst.ItemsSelected
Check for email address.
strEMailRecipient = Nz(lst.Column(1, varItem))
Debug.Print “EMail address: “ & strEMailRecipient
If strEMailRecipient = “” Then
GoTo NextContact
End If
strJobFile = 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 With
Working with External Data 10