[python-win32] WABAccess help ...
Clinton Lee Taylor
clintonlee.taylor at gmail.com
Wed Mar 12 22:09:29 CET 2008
Greetings ...
Take two ... This time I think I found something a little better ...
http://sourceforge.net/projects/wabaccess/
Another LGPL com lib to access Windows Address Book ... But this one
seems to work with Python ...
Okay, so I'm asking again, if anybody (maybe Roger again ... ) Could
help with a basic working example of how to get just something listing
out of the WAB ...
Spend a whole night, with the following code, but can only put stuff
into the WAB, not get a list of e-mail address ...
import win32com.client
objSession = win32com.client.gencache.EnsureDispatch("WABAccess.Session")
print objSession
objSession.Open(False)
if objSession.Identities.LastIdentity ==
"{00000000-0000-0000-0000-000000000000}":
print "No Identity Selected"
else:
print "The Identity " +
objSession.Identities(objSession.Identities.LastIdentity).Name + " is
selected"
print objSession.Identities.DefaultIdentity
print objSession.Identities.Count
print objSession.Containers.Count
objContainer = objSession.Containers(1)
objMyContact=objContainer.Elements.NewContact( False, "Clinton Taylor" )
# FixMe, throught all the constant things would be import somehow ...
PR_EMAIL_ADDRESS = 0x3003001F
PR_BUSINESS_HOME_PAGE = 0x3A51001F
PR_COMPANY_NAME = 0x3A16001F
PR_BUSINESS_ADDRESS_CITY = 0x3A27001F
City = "Paris"
# objCityProperty = objMyContact.Properties.Add(
wabPR_BUSINESS_ADDRESS_CITY, City )
objCityProperty = objMyContact.Properties.Add( PR_BUSINESS_ADDRESS_CITY, City )
# Adding an email address
objMyContact.Properties.Add (PR_EMAIL_ADDRESS, "john.smith at mysociety.com")
# Adding the Web page property
objMyContact.Properties.Add (PR_BUSINESS_HOME_PAGE, "http://www.mysociety.com")
# Adding the company name property
objProperty = objMyContact.Properties.Add(PR_COMPANY_NAME, "")
# Changing the company name property
objProperty.Value = "My Society Name"
objMyContact.ShowDetails
objMyRecipients = objSession.ShowAddress()
objSession.Refresh
objSession.Close
print "Done."
More information about the python-win32
mailing list