MetaPro Systems Inc. Visual Studio Dot Net Tips & Tricks #3 – Direct
Access to
Your Outlook Address Book.
Project Type: VS.NET Windows Application
Code Behind: Visual Basic
I have a project where I needed to access my Outlook Address book
directly. This is possible but very tricky. I got it to work and I
would like to share it with you. Thanks go to Jim Lennox of Scientific
Solutions Inc. for helping me work this out. I would also like to site
the book "Developing Applications using Outlook 2000, CDO, Exchange and
Visual Basic" by Piemonte and Jamison as
a good source for this subject.
I have created a simple project to illustrate this principle. The
project reads the outlook address book and write name, company and email
to a text file. You can download this project from our web site at
http://www.metaprosystems.com/NetTipsTricks.htm
Here are the key portions of the code.
Dim moNS As Outlook.NameSpace
Dim mcContacts As Outlook.MAPIFolder
Dim moItems As Outlook.Items
Dim moCt As Outlook.ContactItem
moNS = mobjOutlook.GetNamespace("mapi")
mcContacts = _
moNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderContacts)
' set to the contact folder
moItems = mcContacts.Items
moItems = moItems.Restrict("[MessageClass] = 'IPM.Contact'")
' filter to select only contact items
moItems.Sort("[EMail1Address]", False) ' sort by email address
Bob Avallone
Copyright 2003.
Comments and questions are welcome. Please forward this entire message
To friends and colleagues. To subscribe or unsubscribe to Dot Net Tips &
Tricks, send an e-mail to ti**@metaprosystems.com or call MetaPro
Systems Inc. at (781) 860-7345.
MetaPro Systems Inc. offers the following services:
* Custom Business Software running under Windows
* Web Sites using ASP.NET
* VS.NET Mentoring
* VS.NET Coaching
For more information about MetaPro’s services, visit
www.metaprosystems.com or
call (781)860-7345.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!