(C) Extract Files from MIME
Extract files from a MIME message.
#include <C_CkMime.h>
#include <C_CkStringArray.h>
void ChilkatSample(void)
{
HCkMime mime;
BOOL success;
HCkStringArray sa;
int i;
int n;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
mime = CkMime_Create();
// Load a MIME document from a file:
// (.mht and .eml files contain MIME).
success = CkMime_LoadMimeFile(mime,"mst.mht");
if (success == FALSE) {
printf("%s\n",CkMime_lastErrorText(mime));
CkMime_Dispose(mime);
return;
}
sa = CkMime_ExtractPartsToFiles(mime,"/temp/mimeParts");
if (CkMime_getLastMethodSuccess(mime) == FALSE) {
printf("%s\n",CkMime_lastErrorText(mime));
CkMime_Dispose(mime);
return;
}
i = 0;
n = CkStringArray_getCount(sa);
// Display the filepaths of the files created:
while (i < n) {
printf("%s\n",CkStringArray_getString(sa,i));
i = i + 1;
}
CkStringArray_Dispose(sa);
CkMime_Dispose(mime);
}
|