As part of a PythonCard sample that I wrote today, I created some code to import Outlook contacts. While the fields I decided to import are specific to the Addresses sample I created for PythonCard, the logic is generic and could be used for other projects. I haven't done much testing with it and I'm sure Mark or some other win32 guru could make suggestions to clean it up, but it does seem to work. The sample is included in whole below. Because of the wrapping problems with email, you can also get at the source here: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pythoncard/PythonCardPrototyp e/samples/addresses/outlook.py If you're interested in the full Addresses sample or anything else PythonCard, the PythonCard home page is at http://pythoncard.sourceforge.net/ The addresses sample will either get included in a prototype daily release that I do later tonight or a general prototype release tomorrow. You can also get the latest version from cvs. ka --- """ __version__ = "$Revision: 1.3 $" __date__ = "$Date: 2001/08/23 02:06:49 $" I need a more generic way of dealing with these modules that may not be available. Also, if the MSOutlook __init__ can't be completed, what's an appropriate failure mechanism? """ try: import win32com.server.util import win32com.client import pythoncom import pywintypes import winerror WIN32_FOUND = 1 except: WIN32_FOUND = 0 import traceback import sys class MSOutlook: def __init__(self): self.outlookFound = 0 try: #oOutlookApp = win32com.client.Dispatch("Outlook.Application.9") self.oOutlookApp = win32com.client.Dispatch("Outlook.Application") self.outlookFound = 1 except: #print "unable to load Outlook" pass self.olFolderInbox = 6 self.olContactItem = 2 self.olFolderContacts = 10 self.olContact = 40 self.olFolderDisplayNormal = 0 self.olMinimized = 1 self.olNormalWindow = 2 self.records = [] def loadRecords(self): if not self.outlookFound: return # this should use more try/except blocks or nested blocks onMAPI = self.oOutlookApp.GetNamespace("MAPI") ofContacts = onMAPI.GetDefaultFolder(self.olFolderContacts) #print "number of contacts:", len(ofContacts.Items) for oc in range(len(ofContacts.Items)): if ofContacts.Items.Item(oc + 1).Class == self.olContact: record = {} record['FullName'] = ofContacts.Items.Item(oc + 1).FullName record['CompanyName'] = ofContacts.Items.Item(oc + 1).CompanyName record['MailingAddressStreet'] = ofContacts.Items.Item(oc + 1).MailingAddressStreet record['MailingAddressCity'] = ofContacts.Items.Item(oc + 1).MailingAddressCity record['MailingAddressState'] = ofContacts.Items.Item(oc + 1).MailingAddressState record['MailingAddressPostalCode'] = ofContacts.Items.Item(oc + 1).MailingAddressPostalCode record['HomeTelephoneNumber'] = ofContacts.Items.Item(oc + 1).HomeTelephoneNumber record['BusinessTelephoneNumber'] = ofContacts.Items.Item(oc + 1).BusinessTelephoneNumber record['MobileTelephoneNumber'] = ofContacts.Items.Item(oc + 1).MobileTelephoneNumber record['Email1Address'] = ofContacts.Items.Item(oc + 1).Email1Address record['Body'] = ofContacts.Items.Item(oc + 1).Body self.records.append(record) #print "InterfaceCount/GatewayCount %d/%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount()) _______________________________________________ ActivePython mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/activepython