(Java) Extract Files from MIME
Extract files from a MIME message.
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkMime mime = new CkMime();
// Load a MIME document from a file:
// (.mht and .eml files contain MIME).
boolean success = mime.LoadMimeFile("mst.mht");
if (success == false) {
System.out.println(mime.lastErrorText());
return;
}
CkStringArray sa = mime.ExtractPartsToFiles("/temp/mimeParts");
if (mime.get_LastMethodSuccess() == false) {
System.out.println(mime.lastErrorText());
return;
}
int i = 0;
int n = sa.get_Count();
// Display the filepaths of the files created:
while (i < n) {
System.out.println(sa.getString(i));
i = i+1;
}
}
}
|