Access.2007.VBA.Bibl..

(John Hannent) #1
& IIf(Nz(![WorkExtension]) <> “”, “ x “ _
& ![WorkExtension], “”)
strMobilePhone = Nz(![MobilePhone])
strFaxNumber = Nz(![FaxNumber])
strNotes = Nz(![Notes])
strStreetAddress = Nz(![StreetAddress])
strCity = Nz(![City])
strStateProv = Nz(![StateOrProvince])
strPostalCode = Nz(![PostalCode])
strCountry = Nz(![Country])

Create a new contact item in the selected Contacts folder.


Set conNew = fldContacts.Items.Add
With conNew
.CustomerID = lngContactID
.FirstName = strFirstName
.LastName = strLastName
.JobTitle = strJobTitle
.BusinessAddressStreet = strStreetAddress
.BusinessAddressCity = strCity
.BusinessAddressState = strStateProv
.BusinessAddressPostalCode = strPostalCode
.BusinessAddressCountry = strCountry
.CompanyName = strCompanyName
.Email1Address = strEMail
.BusinessTelephoneNumber = strBusinessPhone
.BusinessFaxNumber = strFaxNumber
.MobileTelephoneNumber = strMobilePhone
.NickName = strSalutation
.Body = strNotes
.Close (olSave)
End With
lngContactCount = lngContactCount + 1
NextContact:
.MoveNext
Loop
End With

rst.Close

If lngContactCount = 0 Then
MsgBox “No unique contacts to export to Outlook”
Else
MsgBox lngContactCount & “ contact(s) exported to Outlook”
End If

ErrorHandlerExit:
Exit Function

ErrorHandler:

Working with Outlook Items 8

Free download pdf