Access.2007.VBA.Bibl..

(John Hannent) #1

Get Contact ID and name for reference.


lngContactID = Nz(lst.Column(0, varItem))
Debug.Print “Contact ID: “ & lngContactID
strFullName = Nz(lst.Column(1, varItem))

Check for email address.


strEMailRecipient = Nz(lst.Column(2, varItem))
strTest = strEMailRecipient
Debug.Print “Email address: “ & strTest
If strTest = “” Then
blnSomeSkipped = True
strText = “Contact No. “ & lngContactID _
& “ (“ & strFullName _
& “) skipped; no email address”
txt.WriteBlankLines Lines:=1
txt.WriteLine Text:=strText
GoTo NextContactFSO
End If

Check for company name.


strCompanyName = Nz(lst.Column(3, varItem))
strTest = strCompanyName
Debug.Print “Company name: “ & strTest
If strTest = “” Then
blnSomeSkipped = True
strText = “Contact No. “ & lngContactID _
& “ (“ & strFullName _
& “) skipped; no company name”
txt.WriteBlankLines Lines:=1
txt.WriteLine Text:=strText
GoTo NextContactFSO
End If

Has required info; create new mail message and send to contact.


Set msg = appOutlook.CreateItem(olMailItem)
With msg
.To = strEMailRecipient
.Subject = strSubject
.Body = strBody
.Send
End With

NextContactFSO:
Next varItem

Working with Files and Folders 9

Free download pdf