email addresses from Access to Outlook

  • Thread starter Thread starter yvonne
  • Start date Start date
Y

yvonne

I have a database containing 1500 odd contacts, most of
whom have email addresses. I need to be able to take
those email addresses from Access and transfer them to
Outlook so I can then create a group so as to send them
all an email simultaneously.
Can someone please tell me how to do it?
I need help.
 
If I remember correctly, this code comes from a KnowledgeBase article

First, set a reference to the Microsoft Outlook xx.x Object Library, where
xx.x is the version that you are using. Then, put the following code behind
a command button on a form:

Dim oOutlook As New Outlook.Application
Dim colItems As Items
Dim rsCont As Recordset
Dim strSQL As String
Dim strMsg As String

strSQL = "Select ContactName, EmailAddr from tblContacts " _
& "WHERE ContactName is not null and EmailAddr is not null;"

Set rsCont = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)

'Get a reference to the Items collection of the contacts folder.
Set colItems = oOutlook.GetNamespace("MAPI"). _
GetDefaultFolder(olFolderContacts).Items

Do Until rsCont.EOF
If Not blnIsContact(rsCont!ContactName, colItems) Then
With colItems.Add
.FullName = rsCont!ContactName
.Email1Address = rsCont!emailaddr
.Save
End With
End If
rsCont.MoveNext
Loop
rsCont.Close

MsgBox "Done!"

End Sub
END OF CODE TO BE COPIED TO COMMAND BUTTON

PASTE THE FOLLOWING CODE INTO ONE OF YOUR PUBLIC MODULES
Public Function blnIsContact(strName As String, colItems As Items) As
Boolean

Dim varItem As Variant
Dim strMsg As String

'Search for the FullName (strName) in Contacts. If it is found,
'notify the user.
Set varItem = colItems.Find("[FullName] = """ & strName & """")
If varItem Is Nothing Then
blnIsContact = False
Else
strMsg = "The contact named " & strName & " already exists. " _
& Chr(13) & Chr(10) & "Do you want to add this contact
anyway?"

If MsgBox(strMsg, vbYesNo) = vbYes Then
blnIsContact = False
Else
blnIsContact = True
End If
End If

End Function

END OF CODE TO BE COPIED TO PUBLIC MODULE.


HTH,
 
Back
Top