Step 3: Obtain the folder. Take drafts as an example.
Lpspropvalue rgprops = NULL;
Ulong ulvalues = 0;
// Set the desired folder. For details, refer to the introduction to imsgstore on msdn. Here I will list the attribute values of several commonly used Folder:
// Pr_ce_ipm_drafts_entryid drafts, draft box
// Pr_ce_ipm_inbox_entryid inbox, inbox
// Pr_ipm_outbox_entryid outbox, Producer
// Pr_ipm_sentmail_entryid sentbox. I don't know what the mail box is? Is the box of the sent message.
// Pr_ipm_wastebasket_entryid garbage 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 );
// From the code, it can be seen that it is similar to the method for obtaining message store, except that one is taken from the session object and the other is taken from the folder.
While (succeeded (ptable-> queryrows (1, 0, & prows )))
{
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 );
// Every iMessage object obtained here represents every 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;
}
If (prows)
{
Freeprows (prows );
}
If (ptable)
{
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