Unicode C++ Requires Chilkat v11.0.0+
Unicode C++
Export HTML with related images embedded as data URLs
See more Email Object Examples
Read inline-image.eml and produce a single UTF-8 HTML file with its related images embedded. This is useful for a self-contained preview. Treat HTML from received mail as untrusted when displaying it.
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;
success = email.LoadEml(L"inline-image.eml");
if (success != true) {
wprintf(L"%s\n",email.lastErrorText());
return;
}
if (email.HasHtmlBody() != true) {
wprintf(L"This message has no HTML body.\n");
return;
}
CkStringBuilderW html;
success = email.GetHtmlBodySb(true,html);
if (success != true) {
wprintf(L"%s\n",email.lastErrorText());
return;
}
success = html.WriteFile(L"preview.html",L"utf-8",false);
if (success != true) {
wprintf(L"Failed: html.WriteFile.\n");
return;
}
wprintf(L"Saved preview.html.\n");
}