Test for required fields, and exit if any are empty:
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 IfCreate new mail message and send to the current contact:
Set appOutlook = GetObject(, “Outlook.Application”)
Set msg = appOutlook.CreateItem(olMailItem)
With msg
.To = strEMailRecipient
.Subject = strSubject
.Body = strBody
.Display
End WithNextContact:
Next varItemErrorHandlerExit:
Set appOutlook = Nothing
Exit SubErrorHandler:Outlook is not running; open Outlook with CreateObject:
If Err.Number = 429 Then
Set appOutlook = CreateObject(“Outlook.Application”)Organizing and Communicating with Outlook 4