ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-win32
python-win32
Re: [python-win32] MS Exchange address book access within Python
by Tim Golden other posts by this author
Apr 20 2006 8:56AM messages near this date
[python-win32] MS Exchange address book access within Python | [python-win32] Re: Building pywin32 with the free MS toolkitcompiler
[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@[...].org
http://mail.python.org/mailman/listinfo/python-win32
Thread:
Allan Anderson
Tim Golden

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved