Code Repo    |     RSS
MD's Technical Sharing



Sunday, August 10, 2008

Read/Write Office Outlook contacts from .NET

1. Install Office XP/2003/2007
2. Add COM reference to Microsoft Outlook 10/11/12 Object Library


Imports msoutlook = Microsoft.Office.Interop.Outlook


'read

Dim outlookApp As New msoutlook.Application()

Dim outlookNS As msoutlook.NameSpace = outlookApp.GetNamespace("MAPI")

Dim theContacts As msoutlook.MAPIFolder = outlookNS.GetDefaultFolder(msoutlook.OlDefaultFolders.olFolderContacts)

For Each contact As Microsoft.Office.Interop.Outlook.ContactItem In theContacts.Items

Console.WriteLine(contact.FileAs)

Debug.WriteLine(contact.FileAs)

Next


'create new

Dim cnt As msoutlook.ContactItem = CType(outlookApp.CreateItem(msoutlook.OlItemType.olContactItem), msoutlook.ContactItem)

cnt.FileAs = "New Contact"

cnt.MobileTelephoneNumber = "1234567"

cnt.Save()

1 comment:

  1. I know many tools for work with outlook address book. But yesterday no one of theirs couldn't help me. I was very upset. But for luck I obserbed in the Internet - wab recovery. The software solved my problem for a minute and free of charge as I kept in mind. The tool helped some of my friends too and they thanked me.

    ReplyDelete

Note: Only a member of this blog may post a comment.