Zig Requires Chilkat v11.1.0+
Zig
Delete All Email in a POP3 Mailbox
Delete all email in a POP3 mailbox.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 assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// The mailman object is used for receiving (POP3)
// and sending (SMTP) email.
const mailman = try chilkat.MailMan.init();
defer mailman.deinit();
// Set the POP3 server's hostname
mailman.setMailHost("pop.example.com");
// Set the POP3 login/password.
mailman.setPopUsername("bob@example.com");
mailman.setPopPassword("****");
// Make sure the ImmediateDelete property is set (this is the default)
// If ImmediateDelete is not set, messages marked for deletion
// by the Delete* methods will not be deleted until the POP3
// connection is closed by calling Pop3EndSession.
mailman.setImmediateDelete(true);
// First, get all the UIDLs.
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;
};
// Next, delete them all.
mailman.deleteUidlSet(st_uidls) catch {
std.debug.print("{s}\n", .{try mailman.getLastErrorText(alloc)});
return;
};
// We're done with the POP3 session, so it doesn't hurt to call this...
mailman.pop3EndSession() catch {
std.debug.print("{s}\n", .{try mailman.getLastErrorText(alloc)});
return;
};
std.debug.print("Success.\n", .{});
}