Message flags provide you with many options to manipulate mail messages. In fact, you do not write code to perform the low-level operations. You simply set appropriate flags and the system takes care of the rest. For example, if you want to retrieve a message from the Inbox folder only, you set the dwFlags member of the MailMsg structure to MAIL_FOLDER_INBOX before you call MailFirst.
You can use other message flags to enhance the performance of your application. You use MAIL_GET_BODY and MAIL_GET_FLAGS to determine how much of the message is to be read into memory. If you set MAIL_GET_BODY, the entire message is read into memory. Otherwise, everything except the message body is read into memory. In either case, the system allocates memory from the local heap. A handle to the heap is passed back through the hHeap member of the MailMsg structure.
To get minimal information about the messages, without allocating memory, you set dwFlags to MAIL_GET_FLAGS. MAIL_GET_FLAGS instructs the system to read only the dwFlags member of the MailMsg structure. For example, you can build an array of pointers to unopened messages stored in the Inbox folder.
To retrieve a particular message body, you can pass the object identifier to MailGet.