(Java) Extract Files from MIME
Extract files from a MIME message. Note: This example requires Chilkat v11.0.0 or greater.
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[])
{
boolean success = false;
// 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).
success = mime.LoadMimeFile("mst.mht");
if (success == false) {
System.out.println(mime.lastErrorText());
return;
}
CkStringTable st = new CkStringTable();
success = mime.PartsToFiles("/temp/mimeParts",st);
if (success == false) {
System.out.println(mime.lastErrorText());
return;
}
int n = st.get_Count();
// Display the paths of the files created:
int i = 0;
while (i < n) {
System.out.println(st.stringAt(i));
i = i+1;
}
}
}
|