Zig Requires Chilkat v11.0.0+
Zig
Extract Files from MIME
See more MIME Examples
Extract files from a MIME message.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const mime = try chilkat.Mime.init();
defer mime.deinit();
// Load a MIME document from a file:
// (.mht and .eml files contain MIME).
mime.loadMimeFile("mst.mht") catch {
std.debug.print("{s}\n", .{try mime.getLastErrorText(alloc)});
return;
};
const st = try chilkat.StringTable.init();
defer st.deinit();
mime.partsToFiles("/temp/mimeParts", st) catch {
std.debug.print("{s}\n", .{try mime.getLastErrorText(alloc)});
return;
};
const n = st.getCount();
// Display the paths of the files created:
var i: i32 = 0;
while (i < n) {
std.debug.print("{s}\n", .{try st.stringAt(alloc, i)});
i = i + 1;
}
}