CMimeDecode - Implements a MIME decoding class for MFC.
This class can be used in combination with the CPop3Socket class to decode email messages received from a POP3 server.
CMimeDecode supports messages encoded in:
- quoted printable
- not encoded (7 Bit/8 Bit/plain text/html)
BOOL ParseMessage(LPCTSTR lpszMessage);
Split the message into seperate MIME parts.
POSITION GetFirstPart(CMimePart **ppMimePart);
Get the first MIME part in the message.
The POSITION returned by this method can be passed to GetNextPart to get the next MIME part in the message.
POSITION GetNextPart(POSITION pos, CMimePart **ppMimePart);
Get the next MIME part in the message.
The POSITION passed to this method should have been returned by a previous call to GetFirstPart() or GetNextPart() on the same object.
The POSITION returned by this method can be passed to GetNextPart() to get the next MIME part in the message
Remove all parts currently saved in the object.
BOOL DecodeTextPart(CMimePart *pMimePart, CString &strText);
Decodes a MIME part and puts the result in strText.
If succesfully decode to text this method return TRUE.
If the part can not be converted to text it will return FALSE.
base64 and uuencode encoded message cannot be decoded with this method, use DecodeBinaryPart instead.
BOOL DecodeBinaryPart(CMimePart *pMimePart, BYTE **pbDest, int *pnDestLen);
Decodes a MIME part and puts the result in pbDest.
pbDest is a pointer to the address of an unallocated buffer.
pnDestLen is a pointer to a variable that contains the length in bytes of pbDest.
If the function succeeds, the variable receives the number of bytes written to the buffer
If the MIME part is succesfully decoded it allocated enough memory to hold the decoded data.
The caller of this function should free this memory.
BOOL SaveFile(CMimePart *pMimePart, LPCTSTR lpszPath);
Use this method to save the decoded contents of the MIME part to a file.
POSITION pos = mimeDecode.GetFirstPart(&pMimePart);
while (pos != NULL)
pos = mimeDecode.GetNextPart(pos, &pMimePart);
Download demo executable
Download source code
This class is part of the Pablo Software Solutions MFC Extension Package - Classes Edition