Click here to Skip to main content
15,885,278 members
Articles / Programming Languages / C#
Tip/Trick

Global Address Book for Outlook using C# with VSTO

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
30 Jun 2016MIT2 min read 27.6K   887   7  
ContactSharing4OL is an Add-in for Outlook through file server shared contacts item of Outlook in Office area.
This is an old version of the currently published tip/trick.

Introduction

ContactSharing4OL is an Add-in for Outlook through file server shared contacts item of Outlook in office area. It is a VSTO project developed in Visual Studio using C#.

Background

It is a simple tool to attach contacts data (file base) between Outlook and file server that made it a Global address book for Outlook. Once add-in is ready with file server configured, click button 'Global Contacts' will pop up the dialog box which will allow you to select recipients.

Image 1

How Add-in Works

Step 1

Using Visual Studio, create Outlook Add-in project and add new item of Ribbon (XML).

Step 2

Below, add custom button at Outlook inspector.

C#
public string GetCustomUI(string ribbonID)
{
    switch (ribbonID)
    {
        case "Microsoft.Outlook.Mail.Compose":
                    return GetResourceText("ContactSharing4OL.MailComposeInspectorRibbon.xml");
        default:
                    return null;         
    }
}

Code of ContactSharing4OL.MailComposeInspectorRibbon.xml. My custom button is added in default ribbon group "TabNewMailMessage" before "GroupClipboard". So, button will position at top of left.

XML
<?xml version="1.0" encoding="UTF-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon>
    <tabs>
      <tab idMso="TabNewMailMessage">
        <group id="group1" label="ContactSharing" insertBeforeMso="GroupClipboard">
          <button id="GlobalContactBtn" onAction="GlobalContactInspectorRibbonBtn_Click" 
           label="Global Contacts" size="large" getImage="GetGlobalImg"/>
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

Step 3

Once Outook startup add-in will synchronize changed contacts data from server, if local empty will copy all data from server.

C#
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    // ... call my synchronize function here to load data up
}

Points of Interest

Although Microsoft does not provide Address Book Provider API for C#, we can through other activities' API to call what to do in Outlook. Here, I successfully made Address book, it is good for users to achieve Address book functionality without Exchange, Lotus Notes email system.

History

  • 30th June, 2016: Initial release

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Hong Kong Hong Kong
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

Discussions on this specific version of this article. Add your comments on how to improve this article here. These comments will not be visible on the final published version of this article.