First, read system comes with Outlook Express
The basic idea
By loading the Wab32.dll file (this file is generally located below the path "
Implementation
First, including communication thin header files and statements
#include
// internal culvert declaration
Typedef HRESULT (WinApi * Fwabopen) (LPADRBOOK *, LPWABOBJECT *, LPWAB_PARAM, DWORD);
Second, read the detailed code of the specific content
// Read the textual content (type, name, email)
Void cgetemaildlg :: onok ()
{
HRESULT HRES;
LPADRBOOK LPADRBOOK;
LPWABOBJECT LPWABOBOBOBIECT;
LPWAB_PARAM LPWABPARAM = NULL;
DWORD reserved2 = null;
Hinstance hinstlib;
Hinstlib = loadingLibrary ("D: // Program files // common files // system // WAB32");
FWABOPEN Procwabopen;
IF (Hinstlib! = NULL)
{
/ / Get the process address of "WAB32.DLL" internal cullet WABOPEN
Procwabopen = (fwabopen) GetProcadDress (Hinstlib, "Wabopen");
IF (Procwabopen! = NULL)
{
HRES = (Procwabopen) (& lPadrBook, & lpwabiCT, NULL, RESERVED2);
_Asserte (hres == s_ok);
IF (HRES! = S_OK) EXIT (1);
Ulong LPCBENTRYD;
Entryid * LpenTryId;
HRES = lpadrbook-> getPab
& lpcbenTryid,
& lpenTryid
);
_Asserte (hres == s_ok);
IF (HRES! = S_OK) EXIT (2);
Ulong ulflags = mapi_beest_access;
Ulong ulobjtype = null;
LPunknown lpunk = NULL;
hres = lpadrbook-> OpenENTRY
LPCBENTRYID,
LpenTryID,
NULL,
Ulflags,
& ULOBJTYPE,
& lpunk
);
Ulflags = NULL;
IF (ulobjtype == MAPI_ABCONT)
{
Iabcontainer * lpcontainer = static_cast
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
{
SROW * LPROW = & lprows-> AROW [i];
CString Strtemp;
For (Ulong J = 0; 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);
// After reading success, the read button is invalid.
CButton * PBTN = (cbutton *) getDLGITEM (IDOK);
PBTN-> EnableWindow (FALSE);
}
}
Note: When the header file WAB.H is included, sometimes it will be uncovered in WABTAGS.H and other places, and can be modified according to the WABTAGS.H file contained in the sample source code, mainly part of the original installation file. damage.
Second, read the communication thin method in Outlook2k with Office2000
The basic idea
Since Outlook2000 supports internal COM interface, this interface can be used to read the main contents of its internal communication thin.
Implementation
First, introduce the library file of Outlook2000
// Import Read Outlook2000 Communication Thin Content 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")
Second, read the detailed code of the specific content
_ApplicationPtr PAPP;
_Itemsptr pitems;
MapiFolderptr Pfolder; _ContactItemptr PContact;
HRESULT HR;
Try
{
HR = PAPP.CREATEINSTANCE (__ uuidof (application));
IF (Failed (HR))
{
MessageBox ("Outlook Instance Failed", "Error", MB_OK;
Return;
}
/ / Get the contact folder in the default Outlook
PFOLDER = PAPP-> GetNameSpace (_BSTR_T ("MAPI")) -> GetDefaultFolder (OlfolderContacts);
IF (pfolder == null)
{
MessageBox ("No Default Outlook Contact Folder", "Error!");
Return;
}
ELSE / / Otherwise, choose one specified folder in Outlook
{
PFOLDER = PAPP-> GetNameSpace (_BSTR_T ("MAPI") -> PickFolder ();
IF (pfolder == null)
Return;
IF (pfolder-> getdefault ()! = olcontactItem) / / is not a contact
{
MessageBox ("Select Not Contact Folder", "Error");
Return;
}
}
Pitems = Pfolder-> GetItems ();
IF (pitems == null)
{
MessageBox ("You cannot get a contact entry", "error");
Return;
}
PContact = Pitems-> getFirst ();
m_listemail.resetcontent ();
While (1)
{
IF (pcontact == null)
Break;
CString Strtemp;
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 the code to read the contents of the Outlook2000 communication, please pay attention to the points below:
To join the following statement inside the InitInstance (), you will first initialize the COM object: AFXOLINIT (); this can only read the content correctly.
references:
IMPORTING Contacts from Outlook - Deepesh Dhapola
Accessing the windows address book - code4food