Re: [python-win32] getting global addressbook with extended mapi]
Hi Filip, what version of the pythonwin extension do you use ? It should be Build 205, because this Build contains some important changes. regards, Jürgen Hi, Looking around to (ab)use the Exchange GAL from python I found the code snippet listed below, posted to this list last summer. When I try it, I get an exception in the fourth last statement: traceback ... rows = mapi.HrQueryAllRows(...) com_error: (-2147220992, 'CONNECT_E_NOCONNECTION', None, None) /traceback Does anyone have an idea why the connection could have gone lost at that point? Or am I misinterpreting the error? On Thu, Jun 09, 2005 at 05:39:56AM +0200, [EMAIL PROTECTED] wrote: if there are more faint hearted outside, here is the code working for me: code from win32com.mapi.mapitags import * from win32com.mapi import mapi from win32com.mapi import mapiutil profileName = Test session = mapi.MAPIInitialize(None) session =mapi.MAPILogonEx(0,profileName,None, mapi.MAPI_EXTENDED | mapi.MAPI_LOGON_UI |\ mapi.MAPI_NO_MAIL |mapi.MAPI_USE_DEFAULT) hr=session.OpenAddressBook(0,None,mapi.AB_NO_DIALOG) ##open rootcontainer root=hr.OpenEntry(None,None,mapi.MAPI_BEST_ACCESS) ##get items root_htab=root.GetHierarchyTable(0) ##restrict for GAL ##SPropValue should be 'DT_GLOBAL' but not defined in mapitags DT_GLOBAL=131072 restriction = (mapi.RES_PROPERTY, (1, PR_DISPLAY_TYPE, (PR_DISPLAY_TYPE, DT_GLOBAL))) ## get GAL's entryid tuple gal_id = mapi.HrQueryAllRows(root_htab, (PR_ENTRYID), restriction, None, 0) ## extract GAL's entryid gal_id = gal_id[0][0][1] ## open GAL gal=hr.OpenEntry(gal_id,None,mapi.MAPI_BEST_ACCESS) ## get content gal_list=gal.GetContentsTable(0) ## no readable tagname for smpt PR_SMTP=972947486 rows = mapi.HrQueryAllRows(gal_list, (PR_ENTRYID, PR_DISPLAY_NAME_A,PR_ACCOUNT,PR_SMTP), None, None, 0) for eid,name,alias,smtp in rows: print name[1],alias[1],smtp[1] mapi.MAPIUninitialize() /code Regards, Filip ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] getting global addressbook with extended mapi
Hi, Looking around to (ab)use the Exchange GAL from python I found the code snippet listed below, posted to this list last summer. When I try it, I get an exception in the fourth last statement: traceback ... rows = mapi.HrQueryAllRows(...) com_error: (-2147220992, 'CONNECT_E_NOCONNECTION', None, None) /traceback Does anyone have an idea why the connection could have gone lost at that point? Or am I misinterpreting the error? On Thu, Jun 09, 2005 at 05:39:56AM +0200, [EMAIL PROTECTED] wrote: if there are more faint hearted outside, here is the code working for me: code from win32com.mapi.mapitags import * from win32com.mapi import mapi from win32com.mapi import mapiutil profileName = Test session = mapi.MAPIInitialize(None) session =mapi.MAPILogonEx(0,profileName,None, mapi.MAPI_EXTENDED | mapi.MAPI_LOGON_UI |\ mapi.MAPI_NO_MAIL |mapi.MAPI_USE_DEFAULT) hr=session.OpenAddressBook(0,None,mapi.AB_NO_DIALOG) ##open rootcontainer root=hr.OpenEntry(None,None,mapi.MAPI_BEST_ACCESS) ##get items root_htab=root.GetHierarchyTable(0) ##restrict for GAL ##SPropValue should be 'DT_GLOBAL' but not defined in mapitags DT_GLOBAL=131072 restriction = (mapi.RES_PROPERTY, (1, PR_DISPLAY_TYPE, (PR_DISPLAY_TYPE, DT_GLOBAL))) ## get GAL's entryid tuple gal_id = mapi.HrQueryAllRows(root_htab, (PR_ENTRYID), restriction, None, 0) ## extract GAL's entryid gal_id = gal_id[0][0][1] ## open GAL gal=hr.OpenEntry(gal_id,None,mapi.MAPI_BEST_ACCESS) ## get content gal_list=gal.GetContentsTable(0) ## no readable tagname for smpt PR_SMTP=972947486 rows = mapi.HrQueryAllRows(gal_list, (PR_ENTRYID, PR_DISPLAY_NAME_A,PR_ACCOUNT,PR_SMTP), None, None, 0) for eid,name,alias,smtp in rows: print name[1],alias[1],smtp[1] mapi.MAPIUninitialize() /code Regards, Filip -- I decry the current tendency to seek patents on algorithms. There are better ways to earn a living than to prevent other people from making use of one's contributions to computer science. -- D.E. Knuth, TAoCP 3 ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] getting global addressbook with extended mapi
Hi all, Mark wrote: Why? Is something missing, or it just tricky? Sadly, if you want easy, you use CDO/Simple MAPI. Extended MAPI is not for the faint hearted (or for people with deadlines :) I think, that's not a matter of to be clench or not. Diving into a crazy organized library with poor and peripheral dokumentation is just waste of time. But anyway, if there are more faint hearted outside, here is the code working for me: code from win32com.mapi.mapitags import * from win32com.mapi import mapi from win32com.mapi import mapiutil profileName = Test session = mapi.MAPIInitialize(None) session =mapi.MAPILogonEx(0,profileName,None, mapi.MAPI_EXTENDED | mapi.MAPI_LOGON_UI |\ mapi.MAPI_NO_MAIL |mapi.MAPI_USE_DEFAULT) hr=session.OpenAddressBook(0,None,mapi.AB_NO_DIALOG) ##open rootcontainer root=hr.OpenEntry(None,None,mapi.MAPI_BEST_ACCESS) ##get items root_htab=root.GetHierarchyTable(0) ##restrict for GAL ##SPropValue should be 'DT_GLOBAL' but not defined in mapitags DT_GLOBAL=131072 restriction = (mapi.RES_PROPERTY, (1, PR_DISPLAY_TYPE, (PR_DISPLAY_TYPE, DT_GLOBAL))) ## get GAL's entryid tuple gal_id = mapi.HrQueryAllRows(root_htab, (PR_ENTRYID), restriction, None, 0) ## extract GAL's entryid gal_id = gal_id[0][0][1] ## open GAL gal=hr.OpenEntry(gal_id,None,mapi.MAPI_BEST_ACCESS) ## get content gal_list=gal.GetContentsTable(0) ## no readable tagname for smpt PR_SMTP=972947486 rows = mapi.HrQueryAllRows(gal_list, (PR_ENTRYID, PR_DISPLAY_NAME_A,PR_ACCOUNT,PR_SMTP), None, None, 0) for eid,name,alias,smtp in rows: print name[1],alias[1],smtp[1] mapi.MAPIUninitialize() /code PS.: Expanding a distribution lists of the GAL needs to set the address type of that dl to 'MAPIPDL', but I'm lacking the permissions - crazy, crazy regards, Jürgen - This mail sent through IMP: http://horde.org/imp/ ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] getting global addressbook with extended mapi
Hello, I followed Marks hint and tried to get my global addressbook entries with extended mapi. from win32com.mapi import mapiutil from win32com.mapi import exchange import pprint,pythoncom profileName = Test session = mapi.MAPIInitialize(None) session =mapi.MAPILogonEx(0,'test',None, mapi.MAPI_EXTENDED | mapi.MAPI_LOGON_UI |\ mapi.MAPI_NO_MAIL |mapi.MAPI_USE_DEFAULT) hr=session.OpenAddressBook(0,None,mapi.AB_NO_DIALOG) gal = exchange.HrFindExchangeGlobalAddressList (hr) raise: gal = exchange.HrFindExchangeGlobalAddressList (hr) NotImplementedError: Not available with this version of the Exchange SDK So it seems to be that our exchange5.5 SP3 Server don't provide all extended mapi features. But the DumpTopLevelFolders funktion of the class MAPIDriver in spambayes sandbox works fine. How can I find a workaround to access the gal entries ? The final solution should work like the following cdo code: from win32com.client.dynamic import Dispatch s=Dispatch(Mapi.session) s.Logon(, , False, True, 0, True,\ ProfileInfo=/o=myserver/ou=myside/cn=Configuration/cn=myserver\n\nanon) entries=s.AddressLists('Globales Adressbuch').AddressEntries.Item(my distribution list).Members for entr in entries: print entr.Name,entr.Fields(0x39fe001e).Value,entr.Fields(0x3a1e) Any hints ? regards, Jürgen ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32