(C++) Unpack HTML Email to Files
Unpacks an HTML email into an HTML file and related files (images and style sheets). The links within the HTML are updated to point to the files unpacked and saved to disk.
#include <CkEmail.h>
void ChilkatSample(void)
{
CkEmail email;
bool success;
success = email.LoadEml("qa_data/eml/happyHour.eml");
if (success != true) {
std::cout << email.lastErrorText() << "\r\n";
return;
}
// Is this an HTML email?
if (email.HasHtmlBody() == true) {
// Unpack the HTML to files. The image and css URLs
// in the HTML are modified to point to the files extracted to disk.
const char *unpackDir = "qa_output/emails";
const char *partsSubdir = "images";
const char *htmlFilename = "happyHour.html";
success = email.UnpackHtml(unpackDir,htmlFilename,partsSubdir);
if (success != true) {
std::cout << email.lastErrorText() << "\r\n";
return;
}
std::cout << "Success." << "\r\n";
}
}
|