Get the content of this unit

zhaozj2021-02-08  203

Get the content of this unit

Author: Xu Jing Zhou

Download sample source code (http://www.vchelp.net/itbookreview/view_paper.asp?paper_id=737)

(http://www.vckbase.com/document/viewdoc.asp?id=660)

Introduction If you want to get the contents of the native address book (Outlook Express and Outlook2000), such as: contact name, contact email address, etc., you can try the following method.

Since the read Outlook Express and the method taken by the communication thin content in Outlook2000 (Office2000) are different, the following will be separately described. First, the reading system comes with Outlook Express Basic Thoughts Basic Thoughts By loading the WAB32.DLL file (this file is typically located in the path " / program files / compon files / system /" below), The internal culvert WABOPEN process address is called to read the main content of the communication thin.

Specific implementation, including communication thin head files and declarations inside the interior cullette #include // Communication thin head file // internal culvert TYPEDEF HRESULT (WinApi * FwabObiT *, LPWAB_PARAM, DWORD Second, read the detailed code of specific content // read communication thin content (type, name, name, email) vid cgetemails ;: onok () {hResult hres; lpadrbook lpadrbook; lpwabject lpwabibject; lpwab_param lpwabParam = null; DWORD reserved2 = null; hinstance hinstlib; hinstance hinstlib; hinstancy hinstlib; hinstlib = loadingLibrary ("D: // Program files // waomb32"); fwabopen procwabopen; if (hinstlib! = Null) {// Get "WAB32.dll "number of internal Han WABOpen process address procWABOpen = (fWABOpen) GetProcAddress (hinstLib," WABOpen "); if (procWABOpen = NULL!) {hRes = (procWABOpen) (& lpAdrBook, & lpWABObject, NULL, Reserved2); _ASSERTE (hRes == S_ok); if (hres! = S_ok) exit (1); ulong lpcbentryid; entryid * lpenTryid; hres = lpadrbook-> getpab (& lpcbentryid, & lpenTryID) ); _ASSERTE (hRes == S_OK); if (hRes = S_OK) exit (2);! ULONG ulFlags = MAPI_BEST_ACCESS; ULONG ulObjType = NULL; LPUNKNOWN lpUnk = NULL; hRes = lpAdrBook-> OpenEntry (lpcbEntryID, lpEntryID, NULL, Ulflags, & ulobjtype, & lpunk); ulflags = null; if (ulobjtype == mapi_abcont) {ibcontainer * lpcontainer = static_cast (lpunk);

LPMAPITABLE lpTable = NULL; hRes = lpContainer-> GetContentsTable (ulFlags, & lpTable); _ASSERT (lpTable); ULONG ulRows; hRes = lpTable-> GetRowCount (0, & ulRows); _ASSERTE (hRes == S_OK); SRowSet * lpRows; hRes = lptable-> queryRows (ulrows, // Get all rows 0, & lprows); m_listemail.resetcontent (); for (Ulong i = 0; i crows; i ) {slow * lprow = & lprows-> AROW [ I]; cstring straTemp; for (Ulong J = 0; j CVALUES; J ) {spropValue * lpprop = & lprow-> lpprops [j]; if (lpprop-> ulproptag == pr_display_name_a) STRTEMP = STRTEMP "Name:" (char *) lpprop-> value.lpsza; if (lpprop-> ulproptag == pr_Email_address_a) strTemp = Strtemp "Email:" (char *) lpprop-> value.lpsza; If (lpprop-> ulproptag == pr_nickname_a) strTemp = strTemp "said:" (char *) lpprop-> value.lpsza; if (lpprop-> ulproptag == pr_addrtype_a) strTemp = strTemp "

Type: " (char *) lpProp-> Value.lpszA;} m_ListEmail.AddString (strTemp); lpWABObject-> FreeBuffer (lpRow);} lpWABObject-> FreeBuffer (lpRows);}} FreeLibrary (hinstLib); // read After successful, the read button is invalid CButton * PBTN = (cbutton *) getdlgitem (IDOK); PBTN-> EnableWindow (false);}} Note: When you include the header file WAB.H, sometimes WABTAGS.H and other places have not been modified according to the WABTags.h file contained in the sample source code. It is mainly partially damaged by the original installation file. Second, read the basic idea of ​​the communication thin method in Outlook2k in Office2000 Since Outlook2000 supports internal COM interface, this interface can be used to read the main contents of its internal communication thin.

Specifically, the library file of Outlook2000 is imported // Import Read Outlook2000 Communication Thin Content Requirements Requirements #import "E: / Program Files / Microsoft Office / Office / MSO9.DLL" Named_guids #import "E: / Program Files / Microsoft Office / Office / MSOUTL9.olb "/ no_namespace exclude (" _ IRecipientControl "," _DRecipientControl ") two read specific content detailed code _ApplicationPtr pApp; _ItemsPtr pItems; MAPIFolderPtr pFolder; _ContactItemPtr pContact; HRESULT hr; try {hr = Papp.createInstance (__ uuidof (application)); if ("Outlook Instance Creation Failed", "Error", MB_OK; Return;} // Get Contact Folder Pfolder = PAPP in the default Outlook -> GetNameSpace (_BSTR_T ("MAPI")) -> getDefaultfolder; if (pfolder == null) {MessageBox ("No Default Outlook Contact Folder", "Error!"); Return;} Else / / Otherwise, choose Outlook One Specify Folder {PFolder = PAPP-> GetNameSpace (_BSTR_T ("MAPI")) -> PickFolder (); if (PFolder == Null) Return; if (pfolder-> getDefault ()! = lcontactitem) // is not a contact {messagebox ("Select Not Contact Folder", "Error"); Return;}} Pitems = PFolder-> GetItems (); if (Pitems == null) {MessageBox ("No Contact Access", "Error"); Return;} PContact = Pitems-> getFirst (); m_listemail.resetContent (); while (1) {if (pcontact == Break; cstring straTemp;

strTemp = (char *) pContact-> GetFullName (); strTemp = strTemp "<"; strTemp = strTemp (char *) pContact-> GetEmail1Address (); strTemp = strTemp ">"; m_ListEmail.AddString (strTemp) Pcontact = pitems-> getNext ();}} catch (_COM_ERROR & E) {MessageBox ((char *) E.DESCRIPTION ());} Note:

When using code to read Outlook2000 communication, Note the following points: To add the following statement inside the initInstance () Caution to initialize the COM object: AFXOLINIT (); this can only read the content correctly. Reference: Importing Contacts from Outlook - Deepesh Dhapola Accessing The Windows Address Book - Code4food Contact: Address: Six Sixth, No. 2, Labor Road, Xi'an, Shaanxi Province, Zip Code: 710082 Email: Jingzhou_xu@163.net Future Studio (Future Studio )

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

New Post(0)