Ce mapi example (2)

Source: Internet
Author: User

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) =

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,
& 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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.