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

Reply via email to