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 "
Specific implementation, including communication thin head files and declarations inside the interior cullette #include
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
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 )