Thanks for your suggestion and code, Tim. I wound up using the Cookbook recipe here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475179 -Allan
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Golden Sent: Thursday, April 20, 2006 8:56 AM To: python-win32@python.org Subject: Re: [python-win32] MS Exchange address book access within Python [Anderson, Allan] | Hi, folks. I'm working with the gnatsparse.py script included with | Bugzilla to import my company's old GNATS bug database. As this script | appears to have been written specifically for the migration of the GCC | project, and also as it was written for an older version of Bugzilla, | I'm having to make some modifications. | | ... it would be very convenient and result in very correct | data if I simply looked up the addresses and names in our Exchange | address book. I know nothing about how that might work, however. | | Is there a python module that wraps up this sort of handy | functionality? I'm not sure if this is exactly what you're after (or even roughly what you're after) but I hope it's a starting point: <code> import codecs import tempfile import win32api import win32com.client constants = win32com.client.constants session = win32com.client.Dispatch ("MAPI.Session") session.Logon () filename = tempfile.mktemp (suffix=".csv") print "Writing to", filename f = codecs.open (filename, "w", "latin-1") try: address_lists = session.AddressLists gal = address_lists.Item ("Global Address List") addresses = gal.AddressEntries for i in range (addresses.Count): entry = addresses.Item (i + 1) if entry.DisplayType == constants.CdoUser: name = entry.Name smtp = entry.Fields[0x39FE001E] f.write ('"%s","%s"\n' % (name, smtp)) ## print name finally: f.close () session.Logoff () </code> TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32