Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Microsoft Outlook _ Merge Outlook contacts with Access Contacts

Posted by: SimonCleaver Jan 9 2006, 06:29 AM

Hi all,
wonder if anyone could give me some advice.
I have an Access database with "contacts" details and an Outlook pst with Contacts.
I would like to merge the two so I end up with one master list to be used in Outlook. There will be many duplicates as many contacts are duplicated in both databases, but I should end up with a list of about 500 contacts.
Can anyone advise of a effective way of doing this.

Posted by: dallr Jan 9 2006, 08:39 AM

I have never done this but, I am thinking something along these lines would work. I am using office 2003
(A)I would first try and get all my information in one place (Access).
1. In outlook go to FILE ------> IMPORT AND EXPORT----------->. To export your contacts to an excell file.
2. In your access db import the contacts information into the contacts table. (relevant fields of course).
3. Build your query to filter out the duplicate information.
(B)Export the information to Outlook contacts
1. Use a recordset to loop through your query and put your information into outlook.
Take a look at some code i used to loop through a table and email the relevant companies. This should act as a guide for part (B). Of course instead of emailing you would need to use the outlook.contactitem

CODE

Sub Email_Loop()
Dim Conn As ADODB.Connection
Dim rec As ADODB.Recordset
Dim SQL, MailBody As String
Dim OutApp As Outlook.Application
Dim Mail As Outlook.MailItem
Dim Placement As Integer
Dim TimeStart, TimeEnd, Result As Single
[color="green"]  'Open the necessary connections[/color]
Set OutApp = New Outlook.Application
Set Conn = CurrentProject.Connection
Set rec = New ADODB.Recordset
SQL = "SELECT * FROM tblEmployers WHERE (((tblEmployers.EmailAdd) Is Not Null) AND ((tblEmployers.DateEmailSent) Is Null));"
MailBody = " To Whom it May concern."
Placement = CInt(Len(MailBody) + 3)
rec.Open SQL, Conn, adOpenKeyset, adLockOptimistic
TimeStart = Timer 'to time the event
Do Until rec.EOF
    Set Mail = OutApp.CreateItem(olMailItem)
        With Mail
            .Attachments.Add "C:\Oliver.doc", , Placement
            .Body = MailBody
            .Subject = "New Recruitment Agency in Trinidad."
            .To = rec.Fields("EmailAdd")
            .Send
        End With
        
    rec.Fields("DateEmailSent") = Date  'Record the date the email was sent.
    rec.Update
    Debug.Print rec.Fields("emailAdd")  ' for testing purposes only.
    rec.MoveNext
Loop
[color="green"]' To time how long it took to email the records and Number of records. This is not necessarily needed but i had it in for my informtion purposes. [/color]
TimeEnd = Timer
Result = Format(TimeEnd - TimeStart, "0.000")
MsgBox rec.RecordCount & " records were update in;" & Chr(13) & Chr(13) & "Seconds " & Result & Chr(13) _
        & "Minutes " & Round((Result / 60), 2)
rec.Close
Set rec = Nothing
Conn.Close
Set Conn = Nothing
End Sub

Hope this helps

Posted by: MicroE Jan 9 2006, 08:42 AM

Search the code archives for “Outlook” to find working examples of using Access with Outlook.

Posted by: SimonCleaver Jan 11 2006, 10:44 AM

Thanks a lots for the advice