win32com.client (Howto edit Contacts in Outlook)

Tim Golden mail at
Fri Jul 4 15:24:36 CEST 2008

Bill Davy wrote:
> I am trying to edit Contacts in Outlook.  This is so I can transfer numbers 
> from my address book which is an Excel spreadsheet to my mobile phone.  I 
> came across the following snippet of code 

--- hey! that looks familiar :)

> which enabled me to the contacts 
> at least list.  I had to root around to discover CdoDefaultFolderContacts 
> (though it was guessable; how could I enumerate win32com.client.constants?).

Well that bit's easy: win32com.client.constants is a small class with
a __dicts__ attribute (note the "s") which is a list of dictionaries, one
per generated library. So you can do something like this:

import win32com.client

outlook = win32com.client.gencache.EnsureDispatch ("Outlook.Application")
outlook_constants = win32com.client.constants.__dicts__[0]

for k, v in outlook_constants.items ():
  print k, "=>", v


> I now want to work through the Contacts in Outlook patching in data from my 
> spreadsheet, and also making new contacts where there is an entry in my 
> spreadsheet which has not gone into Contacts already.


> Where can I find the API?  

I recommend:




More information about the Python-list mailing list