Unicode C++ Requires Chilkat v11.0.0+
Unicode C++
Create, save, and reopen a plain-text email
See more Email Object Examples
Set the sender, recipient, subject, and plain-text body. Save the result as an EML file, then open it in a second Email object and read its contents.
Chilkat Unicode C++ Downloads
#include <CkEmailW.h>
void ChilkatSample(void)
{
bool success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
CkEmailW email;
email.put_From(L"Sam Lee <sam@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"Hello");
email.put_Body(L"This is a plain-text message.");
success = email.SaveEml(L"message.eml");
if (success != true) {
wprintf(L"%s\n",email.lastErrorText());
return;
}
CkEmailW received;
success = received.LoadEml(L"message.eml");
if (success != true) {
wprintf(L"%s\n",received.lastErrorText());
return;
}
wprintf(L"%s\n",received.ck_from());
wprintf(L"%s\n",received.subject());
wprintf(L"%s\n",received.getPlainTextBody());
}