How to get a folder name for an Outlook Express address book

xiaoxiao2021-04-05  256

[Note]

1. WAB is not stored in each record information 2. IdistList is not a folder information, but group information. 3. Method: First take the entryid and folder name of each folder, and then get the container to which this folder belongs will be obtained. Reverse the Container Table gets all the records in Table. 4. This method has a shortcomings, there is no way to read the records in Share Folder.

// Read Outlook Express Communication Mandi (Folder, Name, Email) Void CGETEMAILDLG :: Onok () {HRESULT HRES; LPADRBOOK LPADRBOOK; LPWABOBJECT LPWABOBIECT

DWORD reserved2 = null;

HINSTANCE hinstLib; hinstLib = LoadLibrary ( "C: // Program Files // Common Files // System // wab32"); fWABOpen procWABOpen; WAB_PARAM wp = {0}; wp.cbSize = sizeof (WAB_PARAM); // Only want TO DEAL with "main Identity's Contacts" wp.ulflags = WAB_ENABLE_PROFLILES; // Set this value, indicating that only the current identity WAB. Remove Share Folder if (hinstlib! = null) {// Get "WAB32.DLL" internal Number of Wabopen ProCwabopen = (fwabopen) GetProcaddress (Hinstlib, "Wabopen");

IF (procwabopen! = null) {hres = (procwabopen) (& lPadrbook, & lpwabject, & wp, reserved2); _ASSERTE (hres == s_ok); if (hres! = s_ok) exit (1);

Ulong lpcbentryid; entryid * LpenTryid; hres = lpadrbook-> getpab (& lpcbentryid, & lpenTryID);

_Asserte (hres! = S_ok) exit (2); ulong ulflags = mapi_best_access; ulong ulobjtype = null; lpunknown lpunk = null; hres = lpadrbook-> OpenENTRY (lpcbentryid, 0, // If the value is set to 0, the obtained will be all directories in WAB. If it is set to & lpenTryID, all contact records NULL, ULFLAGS, & ULOBJTYPE, & lpunk);

Ulflags = WAB_LOCAL_CONTAINERS; // Here Ulflags If set to WAB_PROFILE_CONTENTS, it means that all records are obtained in Container. Resulting in each folder are read out of the recording of all recording // ulFlags = WAB_PROFILE_CONTENTS; if (ulObjType == MAPI_ABCONT) {IABContainer * lpContainer = static_cast (lpUnk); LPMAPITABLE lpTable = NULL; hRes = lpContainer- > GetHierarchyTable (CONVENIENT_DEPTH, & lpTable); // table acquired from the container, table where the stored information folder // hRes = lpContainer-> GetContentsTable (ulFlags, & lpTable); _ASSERT (lpTable); ULONG ulRows; hRes = lpTable- > GetRowCount (0, & Ulrows); // The first parameter is the reserved parameter. Fixed 0 _asserte (hres == s_ok); SROWSET * LPROWS; hRES = lptable-> queryRows (Ulrows, // Get all lines 0, & lprows);

m_ListEmail.ResetContent (); SRow * lpRow = NULL; SPropValue * lpProp = NULL; BOOL bNotFolder = FALSE; IABContainer * lpContainer2 = NULL; LPENTRYID lpEID; ULONG cbEID; for (ULONG i = 0; i cRows; i ) {BNOTFOLDER = false; lprow = & lprows-> aroW [i]; cstring straTemp = _t ("); cstract strm = _t ("); cstract strfoldername = _t ("); for (ulong j = 0; j cValues; j ) {lpProp = & lpRow-> lpProps [j]; if (lpProp-> ulPropTag == PR_DISPLAY_NAME_A) strFolderName = strFolderName "directory:" (char *) lpProp-> Value.lpszA;

IF (LPPROP-> ULPROPTAG == Pr_ENTRYID) {lpeid = (LpenTryID) LPPROP-> value.bin.lpb; cbeid = lpprop-> value.bin.cb;} if (lpprop-> ulproptag == pr_Depth) {IF lpProp-> Value.l == 0) {bNotFolder = TRUE; break;}}} if (bNotFolder) continue; hRes = lpContainer-> OpenEntry (cbEID, lpEID, NULL, ulFlags, & ulObjType, (LPUNKNOWN *) & lpContainer2); LPMAPITABLE lpTable2 = NULL; hRes = lpContainer2-> GetContentsTable (ulFlags, & lpTable2); ULONG ulRows2; hRes = lpTable2-> GetRowCount (0, & ulRows2); SRowSet * lpRows2; hRes = lpTable2-> QueryRows (ulRows2, // get all rows 0, & lprows2); for (ulong i = 0; i crows; i ) {slow * lprow2 = & lprows2-> arow [i]; cstring stretMail = _t ("); cstract strname = _t (" " ); For (ulong j = 0; j cvalues; j ) {spropValue * lpprop2 = & lprow2-> lpprops [j]; if (LPP rop2-> ulPropTag == PR_EMAIL_ADDRESS_A) strEmail = strEmail "Email:" (char *) lpProp2-> Value.lpszA; if (lpProp2-> ulPropTag == PR_DISPLAY_NAME_A) strName = strName "Name:" (char * ) lpProp2-> Value.lpszA;} strTemp = strFolderName strName strEmail; m_ListEmail.AddString (strTemp); lpWABObject-> FreeBuffer (lpRow2);} lpWABObject-> FreeBuffer (lpRows2); lpWABObject-> FreeBuffer (lpRow);} LPWABOBJECT->

转载请注明原文地址:https://www.9cbs.com/read-132119.html

New Post(0)