Zig
Zig
IMAP Session Logging
Demonstrates how to use session logging with IMAP.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.
const imap = try chilkat.Imap.init();
defer imap.deinit();
// Set the KeepSessionLog property to enable IMAP session logging
imap.setKeepSessionLog(true);
// Connect to an IMAP server.
// Use TLS
imap.setSsl(true);
imap.setPort(993);
imap.connect("imap.example.com") catch {
std.debug.print("{s}\n", .{try imap.getLastErrorText(alloc)});
return;
};
// Login
imap.login("mylogin", "mypassword") catch {
std.debug.print("{s}\n", .{try imap.getLastErrorText(alloc)});
return;
};
// Select an IMAP mailbox
imap.selectMailbox("Inbox") catch {
std.debug.print("{s}\n", .{try imap.getLastErrorText(alloc)});
return;
};
// We're not really doing anything in this example
// other than to show how to examine the IMAP component's session log...
// Disconnect from the IMAP server.
try imap.disconnect();
// Display the session log...
std.debug.print("{s}\n", .{try imap.getSessionLog(alloc)});
}