Unicode C++ Requires Chilkat v11.0.0+
Unicode C++
Choose the character set for an HTML email
See more Email Object Examples
Read a UTF-8 HTML file as Unicode, then set the charset Chilkat will use when writing the MIME text. The HTML file’s input encoding and the message’s output charset are separate choices. UTF-8 can represent names from multiple writing systems.
Chilkat Unicode C++ Downloads
#include <CkEmailW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
bool success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
CkEmailW email;
email.put_From(L"Workshop team <events@example.com>");
success = email.AddTo(L"Alex Rivera",L"alex@example.net");
if (success != true) {
wprintf(L"%s\n",email.lastErrorText());
return;
}
email.put_Subject(L"Workshop registration");
CkStringBuilderW html;
success = html.LoadFile(L"newsletter.html",L"utf-8");
if (success != true) {
wprintf(L"Failed: html.LoadFile.\n");
return;
}
email.put_Charset(L"utf-8");
email.SetHtmlBody(html.getAsString());
success = email.SaveEml(L"newsletter.eml");
if (success != true) {
wprintf(L"%s\n",email.lastErrorText());
return;
}
wprintf(L"Saved newsletter.eml.\n");
}