Zig Requires Chilkat v11.0.0+
Zig
POP3 Fetch Mime Source of Email by UIDL
Demonstrates how to fetch the MIME source of a single email by UIDL.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 mailman = try chilkat.MailMan.init();
defer mailman.deinit();
mailman.setMailHost("pop.example.com");
mailman.setPopUsername("myLogin");
mailman.setPopPassword("myPassword");
mailman.setMailPort(995);
mailman.setPopSsl(true);
const st_uidls = try chilkat.StringTable.init();
defer st_uidls.deinit();
mailman.fetchUidls(st_uidls) catch {
std.debug.print("{s}\n", .{try mailman.getLastErrorText(alloc)});
return;
};
// Download each email as MIME.
const bd_mime = try chilkat.BinData.init();
defer bd_mime.deinit();
const count = st_uidls.getCount();
var i: i32 = 0;
while (i < count) {
mailman.fetchMimeBd(try st_uidls.stringAt(alloc, i), bd_mime) catch {
std.debug.print("{s}\n", .{try mailman.getLastErrorText(alloc)});
return;
};
// Do whatever is needed with the MIME contained in bdMime.
i = i + 1;
}
}