Unicode C
Unicode C
Get an Email's MIME into a StringBuilder
See more Email Object Examples
Demonstrates the Chilkat Email.GetMimeSb method, which returns the email as MIME text (header, body or bodies, related items, and all attachments) by appending it to a StringBuilder object. This example builds a message and appends its MIME to a StringBuilder.
Background: This is a
StringBuilder-based alternative to GetMime, which returns a plain string. Writing into a StringBuilder is more efficient when the MIME is large or when you intend to further manipulate it — searching, replacing, or accumulating additional text — without creating many intermediate string copies.Chilkat Unicode C Downloads
#include <C_CkEmailW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
BOOL success;
HCkEmailW email;
HCkStringBuilderW sbMime;
success = FALSE;
// Demonstrates the GetMimeSb method, which returns the email as MIME text (headers, bodies,
// related items, and attachments), appending it to a StringBuilder object.
email = CkEmailW_Create();
CkEmailW_putSubject(email,L"GetMimeSb example");
CkEmailW_putFrom(email,L"alice@example.com");
CkEmailW_AddTo(email,L"Bob",L"bob@example.com");
CkEmailW_putBody(email,L"Hello!");
// Append the complete MIME to a StringBuilder.
sbMime = CkStringBuilderW_Create();
success = CkEmailW_GetMimeSb(email,sbMime);
if (success == FALSE) {
wprintf(L"%s\n",CkEmailW_lastErrorText(email));
CkEmailW_Dispose(email);
CkStringBuilderW_Dispose(sbMime);
return true;
}
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbMime));
CkEmailW_Dispose(email);
CkStringBuilderW_Dispose(sbMime);
}