Step 3: Obtain the folder. Take drafts as an example.
lpspropvalue rgprops = NULL;
ulong ulvalues = 0;
// set the folder we want to use. For details, refer to the msdn introduction to imsgstore, here I will list the attribute values of several commonly used Folder:
// pr_ce_ipm_drafts_entryid drafts, draft box
// inbox, inbox
// pr_ipm_outbox_entryid outbox, sender
// pr_ipm_sentmail_entryid sentbox. What is the mail box? Is the box where the sent message is placed.
// pr_ipm_wastebasket_entryid bin
ulong rgtags [] = {1, pr_ce_ipm_drafts_entryid};
// Obtain the entry ID of the folder and obtain the object through openentry.
Pmsgstore-> getprops (lpsproptagarray) rgtags, mapi_unicode, & ulvalues, & rgprops );
Pmsgstore-> openentry (rgprops [0]. value. bin. CB, (lpentryid) rgprops [0]. value. bin. LPB, null, mapi_modify, null, (lpunknown *) pfolder );
Mapifreebuffer (rgprops );
In this way, I got the desired folder, and the last thing left is to traverse the message. In fact, the process is very similar to the process of getting the store.
Step 4: get the message.
Lpmapitable ptable = NULL;
Lpsrowset prows = NULL;
Ulong ulnumcols = 1;
// Specify the entry ID attribute.
Sizedsproptagarray (ulnumcols, columns) =
{
Ulnumcols,
Pr_entryid
};
pfolder-> getcontentstable (0, & ptable);
hR = ptable-> setcolumns (lpsproptagarray) & columns, 0 );
// The Code shows that it is similar to the method used to obtain message store, only one is from the session object, and the other is from the folder.
while (succeeded (ptable-> queryrows (1, 0, & prows)
{< br> lpmessage PMSG = NULL;
ulong ulmesagetype;
// obtain the iMessage object through openentry
pfolder-> openentry (prows-> Arow [0]. lpprops [0]. value. bin. CB,
(lpentryid) prows-> Arow [0]. lpprops [0]. value. bin. LPB,
null,
mapi_best_access,
& ulmesagetype,
(lpunknown *) & PMSG );
// each iMessage object obtained here represents each message in the folder. You can perform operations on it. To obtain the desired information.
......
// release note when not required
PMSG-> release ();
freeprows (prows);
prows = NULL;
}< br> If (prows)
{< br> freeprows (prows);
}< br> If (ptable)
{< br> ptable-> release ();
}
Finally, I wrote it for the first time. I don't know what to say. If something is wrong, please correct it.
Bored customers
2005.8.11
Yzx0023@gmail.com