def search_start(self, folders, text, recurse=False): # specific restriction format, needed to reach indexer restriction = SOrRestriction([ SContentRestriction(FL_SUBSTRING | FL_IGNORECASE, PR_SUBJECT_W, SPropValue(PR_SUBJECT_W, str(text))), SContentRestriction(FL_SUBSTRING | FL_IGNORECASE, PR_BODY_W, SPropValue(PR_BODY_W, str(text))), SContentRestriction(FL_SUBSTRING | FL_IGNORECASE, PR_DISPLAY_TO_W, SPropValue(PR_DISPLAY_TO_W, str(text))), SContentRestriction(FL_SUBSTRING | FL_IGNORECASE, PR_DISPLAY_NAME_W, SPropValue(PR_DISPLAY_NAME_W, str(text))), # TODO add all default fields.. # BUT perform full-text search by default! ]) if isinstance(folders, Folder): folders = [folders] search_flags = 0 if recurse: search_flags = SEARCH_RECURSIVE self.mapiobj.SetSearchCriteria(restriction, [_bdec(f.entryid) for f in folders], search_flags)
def restriction(self, type_, store): if self.op == 'AND': return SAndRestriction( [arg.restriction(type_, store) for arg in self.args]) elif self.op == 'OR': return SOrRestriction( [arg.restriction(type_, store) for arg in self.args]) elif self.op == 'NOT': return SNotRestriction(self.args[0].restriction(type_, store))
def GetGab(session): ab = session.OpenAddressBook(0, None, 0) root = ab.OpenEntry(None, None, 0) table = root.GetHierarchyTable(0) table.SetColumns([PR_ENTRYID], TBL_BATCH) restriction = SOrRestriction([ SPropertyRestriction(RELOP_EQ, PR_DISPLAY_TYPE, SPropValue(PR_DISPLAY_TYPE, DT_GLOBAL)), SAndRestriction([ SExistRestriction(PR_EMS_AB_CONTAINERID), SPropertyRestriction(RELOP_EQ, PR_EMS_AB_CONTAINERID, SPropValue(PR_EMS_AB_CONTAINERID, 0)) ]) ]) table.FindRow(restriction, BOOKMARK_BEGINNING, 0) eid = table.QueryRows(1, 0)[0][0].Value return ab.OpenEntry(eid, None, 0)