C
C
Extract Files from MIME
See more MIME Examples
Extract files from a MIME message.Chilkat C Downloads
#include <C_CkMime.h>
#include <C_CkStringTable.h>
void ChilkatSample(void)
{
BOOL success;
HCkMime mime;
HCkStringTable st;
int n;
int i;
success = FALSE;
// 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;
}
st = CkStringTable_Create();
success = CkMime_PartsToFiles(mime,"/temp/mimeParts",st);
if (success == FALSE) {
printf("%s\n",CkMime_lastErrorText(mime));
CkMime_Dispose(mime);
CkStringTable_Dispose(st);
return;
}
n = CkStringTable_getCount(st);
// Display the paths of the files created:
i = 0;
while (i < n) {
printf("%s\n",CkStringTable_stringAt(st,i));
i = i + 1;
}
CkMime_Dispose(mime);
CkStringTable_Dispose(st);
}