win32com.client (Howto edit Contacts in Outlook)
Tim Golden
mail at timgolden.me.uk
Fri Jul 4 09:24:36 EDT 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:
<code>
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
</code>
> 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.
OK.
> Where can I find the API?
I recommend:
http://msdn.microsoft.com/en-us/library/ms526861.aspx
and
http://www.outlookcode.com/article.aspx?id=20
and
http://www.cdolive.com/cdo10.htm
TJG
More information about the Python-list
mailing list