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 <CkMailManW.h>
#include <CkEmailW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
bool 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).
CkMailManW mailman;
// Build the email to render.
CkEmailW email;
email.put_Subject(L"Rendered email");
email.put_From(L"alice@example.com");
email.AddTo(L"Bob",L"bob@example.com");
email.put_Body(L"This message is rendered to MIME in a StringBuilder.");
// Render the MIME into a StringBuilder.
CkStringBuilderW sbMime;
success = mailman.RenderToMimeSb(email,sbMime);
if (success == false) {
wprintf(L"%s\n",mailman.lastErrorText());
return;
}
wprintf(L"%s\n",sbMime.getAsString());
}