| 1 |
ninoborges |
8 |
## This program will get the number of contacts in the users outlook contacts list
|
| 2 |
|
|
## 10.28.03
|
| 3 |
|
|
## EBorges
|
| 4 |
|
|
|
| 5 |
|
|
from win32com.client import Dispatch
|
| 6 |
|
|
from win32com.client import constants
|
| 7 |
|
|
from win32com.client import gencache
|
| 8 |
|
|
|
| 9 |
|
|
# To ensure outlook is supported and found on other machines
|
| 10 |
|
|
gencache.EnsureModule('{00062FFF-0000-0000-C000-000000000046}', 0, 9, 1)
|
| 11 |
|
|
s = Dispatch("Outlook.Application")
|
| 12 |
|
|
ns = s.GetNamespace("MAPI")
|
| 13 |
|
|
namesList = open("\\\\ric1\\7312\\commence_admin\\commence_HasContacts\\CommenceList.txt",'r').readlines()
|
| 14 |
|
|
o = open("\\\\ric1\\7312\\commence_admin\\commence_HasContacts\\CommenceContactsList.txt",'a')
|
| 15 |
|
|
for name in namesList:
|
| 16 |
|
|
Recipient = ns.CreateRecipient(name)
|
| 17 |
|
|
resolved = Recipient.Resolve()
|
| 18 |
|
|
if resolved:
|
| 19 |
|
|
folder = ns.GetSharedDefaultFolder(Recipient,constants.olFolderContacts)
|
| 20 |
|
|
contactCount = len(folder.Items)
|
| 21 |
|
|
o.write("%s has %i contacts\n"% (name.split('\n')[0],contactCount))
|
| 22 |
|
|
print "%s has %i contacts"% (name.split('\n')[0],contactCount)
|
| 23 |
|
|
o.close()
|
| 24 |
|
|
|
| 25 |
|
|
#contacts = ns.GetDefaultFolder(10)
|
| 26 |
|
|
#numbOfContacts = len(contacts.Items)
|
| 27 |
|
|
#print "You have %i Contacts"% numbOfContacts |