Unicode C
Unicode C
Render an Email to MIME in a StringBuilder
See more SMTP Examples
Demonstrates the Chilkat MailMan.RenderToMimeSb method, which renders an Email object as MIME text and appends the result to a StringBuilder, without sending the email. This example renders a message into a StringBuilder and prints it.
Background: This is the
StringBuilder version of RenderToMime. Appending into a StringBuilder is more efficient when the MIME is large or when you plan to further inspect or manipulate it — searching, replacing, or accumulating additional text — without creating extra intermediate string copies.Chilkat Unicode C Downloads
#include <C_CkMailManW.h>
#include <C_CkEmailW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
BOOL success;
HCkMailManW mailman;
HCkEmailW email;
HCkStringBuilderW sbMime;
success = FALSE;
// Demonstrates the MailMan.RenderToMimeSb method, which renders an Email object as MIME text
// and appends the result to a StringBuilder (without sending the email).
mailman = CkMailManW_Create();
// Build the email to render.
email = CkEmailW_Create();
CkEmailW_putSubject(email,L"Rendered email");
CkEmailW_putFrom(email,L"alice@example.com");
CkEmailW_AddTo(email,L"Bob",L"bob@example.com");
CkEmailW_putBody(email,L"This message is rendered to MIME in a StringBuilder.");
// Render the MIME into a StringBuilder.
sbMime = CkStringBuilderW_Create();
success = CkMailManW_RenderToMimeSb(mailman,email,sbMime);
if (success == FALSE) {
wprintf(L"%s\n",CkMailManW_lastErrorText(mailman));
CkMailManW_Dispose(mailman);
CkEmailW_Dispose(email);
CkStringBuilderW_Dispose(sbMime);
return;
}
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbMime));
CkMailManW_Dispose(mailman);
CkEmailW_Dispose(email);
CkStringBuilderW_Dispose(sbMime);
}