Unicode C
Unicode C
Serialize MIME to a String
See more MIME Examples
Demonstrates the Chilkat Mime.GetMime method, which serializes and returns the complete MIME entity — headers, body, multipart boundaries, and all descendants — as a string. It takes no arguments.
Background: This produces the finished MIME text ready to send, store, or hand to another component — the inverse of loading. The whole tree is emitted, including generated multipart boundaries. Because it returns a string, it is best for text-safe content; when the body may contain raw binary bytes, serialize with
GetMimeBd to a BinData instead so nothing is altered.Chilkat Unicode C Downloads
#include <C_CkMimeW.h>
void ChilkatSample(void)
{
BOOL success;
HCkMimeW mime;
const wchar_t *mimeText;
success = FALSE;
// Demonstrates the Mime.GetMime method, which serializes and returns the complete MIME entity
// (headers, body, multipart boundaries, and all descendants) as a string. It takes no
// arguments.
mime = CkMimeW_Create();
// Build a simple MIME entity.
success = CkMimeW_SetBodyFromPlainText(mime,L"Hello, this is the message body.");
if (success == FALSE) {
wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
CkMimeW_Dispose(mime);
return;
}
// Serialize it to a string.
mimeText = CkMimeW_getMime(mime);
if (CkMimeW_getLastMethodSuccess(mime) == FALSE) {
wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
CkMimeW_Dispose(mime);
return;
}
wprintf(L"%s\n",mimeText);
CkMimeW_Dispose(mime);
}