Getting Outlook Contact Counts

jrunowski

Member
Joined
Aug 23, 2006
Messages
15
Programming Experience
Beginner
I wanted to get a list of all my MS Exchange users and their contact counts. I found code from the MSDN to get contact counts but thats just for my session. Is it possible to get all users contact counts?

Here is the code i found:
VB.NET:
[SIZE=2][COLOR=#0000ff][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] get_count()
[/SIZE][SIZE=2][COLOR=#008000]' Create Outlook application.
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] oApp [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Outlook.Application = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Outlook.Application()
[/SIZE][SIZE=2][COLOR=#008000]' Get NameSpace and Logon.
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] oNS [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Outlook.NameSpace = oApp.GetNamespace([/SIZE][SIZE=2][COLOR=#800000]"mapi"[/COLOR][/SIZE][SIZE=2])
oNS.Logon([/SIZE][SIZE=2][COLOR=#800000]"Outlook"[/COLOR][/SIZE][SIZE=2], Missing.Value, [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#008000]' TODO:
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' Get the first contact from the Contacts folder.
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] cContacts [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] oItems [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Outlook.Items = cContacts.Items
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] oCt [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Outlook.ContactItem
[/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2]counter = oItems.Count()
[/SIZE][SIZE=2][COLOR=#008000]'oCt = oItems.Count()
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception
MsgBox(ex.Message)
[/SIZE][SIZE=2][COLOR=#0000ff]Finally
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' Display
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'oCt.Display(True)
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' Log off.
[/COLOR][/SIZE][SIZE=2]oNS.Logoff()
[/SIZE][SIZE=2][COLOR=#008000]' Clean up.
[/COLOR][/SIZE][SIZE=2]oApp = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing
[/COLOR][/SIZE][SIZE=2]oNS = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing
[/COLOR][/SIZE][SIZE=2]oItems = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing
[/COLOR][/SIZE][SIZE=2]oCt = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][/COLOR][/SIZE]
 
Back
Top