[Spambayes] Outlook plugin & Bad Folders

Meyer, Tony T.A.Meyer at massey.ac.nz
Fri Jan 17 17:16:58 EST 2003


OK, I've solved the MAPI/Exchange problem, I think.  What was happening was that we were storing a short term id, not a long term one.  This is why the id worked when buliding the list, but not later on.  See this for more information:

<http://msdn.microsoft.com/library/en-us/mapi/html/_mapi1book_pr_entryid.asp>

It now works for me - builds the tree, and I can use the results (i.e. filter on a selected folder).  Unfortunately, my copy of FolderSelector.py is stuffed because I've played around with it so much, and I can't check out a new copy because of the sourceforge cvs problem.  This is my new _BuildFoldersMAPI function, which is all that needs to be changed (plus changing FilterDialog.py, TrainingDialog.py and FolderSelector.py to use MAPI and not Outlook tree builds).

def _BuildFoldersMAPI(msgstore, folder):
    # Get the hierarchy table for it.
    table = folder.GetHierarchyTable(0)
    children = []
    rows = mapi.HrQueryAllRows(table, (PR_ENTRYID,
                                       PR_STORE_ENTRYID,
                                       PR_DISPLAY_NAME_A), None, None, 0)
    for (eid_tag, eid),(storeeid_tag, store_eid), (name_tag, name) in rows:
        folder_id = mapi.HexFromBin(store_eid), mapi.HexFromBin(eid)
        spec = FolderSpec(folder_id, name)
        try:
            child_folder = msgstore.OpenEntry(eid, None, mapi.MAPI_DEFERRED_ERRORS)
            prop_ids = PR_ENTRYID, PR_STORE_ENTRYID
            hr, data = child_folder.GetProps(prop_ids,0)
            folder_eid = data[0][1]
            spec.folder_id = mapi.HexFromBin(store_eid), mapi.HexFromBin(folder_eid)
        except pythoncom.error:
            # Something strange with this folder - just ignore it
            spec = None
        if spec is not None:
            spec.children = _BuildFoldersMAPI(msgstore, child_folder)
            children.append(spec)
    return children

The bad news, of course, is that this (I believe) means that MAPI works, but that means my nice build-on-demand code is broken.  I guess I'll have to re-implement in using MAPI...<sigh>

=Tony Meyer



More information about the Spambayes mailing list