(Unicode C) Extract Files from MIME
Extract files from a MIME message.
#include <C_CkMimeW.h>
#include <C_CkStringArrayW.h>
void ChilkatSample(void)
{
HCkMimeW mime;
BOOL success;
HCkStringArrayW sa;
int i;
int n;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
mime = CkMimeW_Create();
// Load a MIME document from a file:
// (.mht and .eml files contain MIME).
success = CkMimeW_LoadMimeFile(mime,L"mst.mht");
if (success == FALSE) {
wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
CkMimeW_Dispose(mime);
return;
}
sa = CkMimeW_ExtractPartsToFiles(mime,L"/temp/mimeParts");
if (CkMimeW_getLastMethodSuccess(mime) == FALSE) {
wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
CkMimeW_Dispose(mime);
return;
}
i = 0;
n = CkStringArrayW_getCount(sa);
// Display the filepaths of the files created:
while (i < n) {
wprintf(L"%s\n",CkStringArrayW_getString(sa,i));
i = i + 1;
}
CkStringArrayW_Dispose(sa);
CkMimeW_Dispose(mime);
}
|