connect outlook and/or exchange contacts folder odbc data source

Posted on 2005-03-30
Medium Priority
Last Modified: 2012-02-20
I have a database that holds customer name, addresses, phone numbers, etc. I want to make this data
available, readonly, to all users in an outlook contacts folder (currently outlook 2000, but could become 2003)
We also have exchange server 2003.

It's similiar to this question
but should run offline rather than when outlook is started up.

There used to be a product called orbis intelliware that did this but it's no longer available
Question by:NickUpson
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 3
LVL 76

Expert Comment

by:David Lee
ID: 13662597
Hi NickUpson,
> run offline
What do you mean by this?  Do you envision the processing running like a scheduled task?

LVL 19

Author Comment

ID: 13663593
We could accept it running every night = offline or, ideally, completely syncronised, getting the data whenever it's accessed
LVL 21

Expert Comment

ID: 13664873
Sounds like you want to use a public folder.  Have you considered that option, and if so is there a reason it doesn't suit your needs?
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

LVL 19

Author Comment

ID: 13664985
a public folder is fine, the problem is how to connect a public folder to an odbc datasource
LVL 21

Expert Comment

ID: 13665455
Any custom fields in the Outlook contacts?

Is this importing from Access?
LVL 19

Author Comment

ID: 13666191
standard default outlook contacts fields but no it's not access (actually firebird) therefore only accessible via ODBC
LVL 21

Expert Comment

ID: 13666495
Are you looking to create a custom solution yourself?  

If not there are probably utilities which will suit your needs.  See this:
http://www.mapistore.com/Outlook/Contacts/Review_00766_index.html (free download)
http://www.hidownload.com/products/6/34/6-34-666.htm (free trial $65 to purchase)

Several other solutions are listed at this site:
LVL 76

Expert Comment

by:David Lee
ID: 13666509
>getting the data whenever it's accessed
Depending on the size of the database that doesn't seem very practical and I don't know how you'd go about trapping an event indicating that someone was accessing the contacts.  It'd make more sense to have an external process that was kicked off whenever the database changed, syncing Outlook to it.  I don't know anything about Firebird, in fact I've never heard of it before.  If it's programmable, then maybe something could be written into it that'd run the syncing process immediately after any changes were made to the data.  An alternative would be to write an update routine in VB or VBScript and schedule it to ran however often you deem necessary using the Windows Task Scheduler.
LVL 19

Author Comment

ID: 13669300
Ideally when someone accesses the folder, an sql statement would run to populate it so no problem with events
LVL 76

Expert Comment

by:David Lee
ID: 13670314
I don't believe that's going to be possible.  That's what I was mentioning, there's no event I know of that's triggered when a person accesses a folder.  
LVL 19

Author Comment

ID: 13672070
a process that ran every night to reload them would be acceptable
LVL 76

Expert Comment

by:David Lee
ID: 13680150
Do you use all the contact fields or only a subset?  If the latter, which ones?  Also, do the database fields have the same names?
LVL 19

Author Comment

ID: 13680525
not all of them, there must be 100. just basic ones like name, company, business phone, busiesss fax, etc.
the database fields don't have the same names but I could probably put a view in between if necessary
LVL 76

Accepted Solution

David Lee earned 2000 total points
ID: 13680844
Here's the code.  To use it:
1.  Open Notepad
2.  Copy the code and paste it into Notepad
3.  Edit the code as required, making sure to make the changes per the comments in the code
4.  Save the file.  You can name it anything you want so long as it ends with .vbs
5.  Run the script as a test
6.  Create a scheduled task that'll run the script each night

The script relys on Outlook so it must run on a computer that has Outlooked installed.  I built and tested this on a computer using Outlook 2002 and it worked without a hitch.

'Code begins here
'Open the database
Set adoCon = CreateObject("ADODB.Connection")
'Change the connection string to the one required for your database
adoCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\eeTesting\Contacts.Mdb;Persist Security Info=False"
adoCon.CursorLocation = 2
Set adoRS = CreateObject("ADODB.RecordSet")
'Change Contacts to the name of the table in your database
adoRS.Open "Contacts", adoCon, 0, 1
'Open Outlook
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
'Change Outlook to the name of your Outlook profile
olNS.Logon "Outlook"
'Change the folder path to that of your shared contact folder
Set olContactFolder = OpenMAPIFolder("\Lee, David\eeTesting\Contacts")
'Delete all the existing contacts (it's simpler to re-add them all)
For intCounter = olContactFolder.Items.Count To 1 Step -1
With adoRS
    'Read the database records
    While Not .EOF
        'Create a contact
        Set olContact = olApp.CreateItem(2)
        'Fill in the contact's fields
        'Edit the list of fields as needed
        olContact.BusinessTelephoneNumber = .Fields("BusinessPhone")
        olContact.CompanyName = .Fields("Company")
        olContact.Email1Address = .Fields("Email")
        olContact.FirstName = .Fields("Firstname")
        olContact.LastName = .Fields("Lastname")
        olContact.MailingAddress = .Fields("Mailing")
        olContact.Title = .Fields("Title")
        'Save the contact to the default contact folder
        'Move the contact to the proper folder
        olContact.Move olContactFolder
End With
'Clean up
Set adoRS = Nothing
Set adoCon = Nothing
Set olContact = Nothing
Set olContactFolder = Nothing
Set olNS = Nothing
Set olApp = Nothing

'Credit where credit is due.
'The code below is not mine.  I found it somewhere on the internet but do
'not remember where or who the author is.  The original author(s) deserves all
'the credit for these functions.
Function OpenMAPIFolder(szPath)
    Dim app, ns, flr, szDir, i
    Set flr = Nothing
    Set app = CreateObject("Outlook.Application")
    If Left(szPath, Len("\")) = "\" Then
        szPath = Mid(szPath, Len("\") + 1)
        Set flr = app.ActiveExplorer.CurrentFolder
    End If
    While szPath <> ""
        i = InStr(szPath, "\")
        If i Then
            szDir = Left(szPath, i - 1)
            szPath = Mid(szPath, i + Len("\"))
            szDir = szPath
            szPath = ""
        End If
        If IsNothing(flr) Then
            Set ns = app.GetNamespace("MAPI")
            Set flr = ns.Folders(szDir)
            Set flr = flr.Folders(szDir)
        End If
    Set OpenMAPIFolder = flr
End Function

Function IsNothing(Obj)
  If TypeName(Obj) = "Nothing" Then
    IsNothing = True
    IsNothing = False
  End If
End Function
'Code ends here

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question