Dim oOutlook As New Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oContacts As Outlook.MAPIFolder
Dim oItems As Outlook.Items
oNS = oOutlook.GetNamespace("mapi")
oContacts = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
' set to the contact folder
oItems = oContacts.Items.Restrict("[MessageClass] = 'IPM.Contact'")
' filter to select only contact items
oItems.Sort("[EMail1Address]", False) ' sort by email address
For Each oct As Outlook.ContactItem In oItems
MessageBox.Show(oct.CompanyName & "-" & oct.BusinessTelephoneNumber)
Next
Tuesday, June 19, 2007
Accessing Outlook Address Book from VB.NET
Had someone ask me this a while back and lost the link so I decided to blog it this time. As always dont' forget to add a COM reference to your project for the Microsoft.Outlook x.0 Object library in order to create the necessary objects.
Subscribe to:
Post Comments (Atom)
1 comment:
I have req. to launch the Address book window.
Post a Comment