Zig Requires Chilkat v11.0.0+
Zig
Access Attached Message (Embedded Email)
How to access an email embedded within another email (i.e. an attached 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();
const email = try chilkat.Email.init();
defer email.deinit();
// Load an email from a .eml
email.loadEml("embeddedEmail.eml") catch {
std.debug.print("{s}\n", .{try email.getLastErrorText(alloc)});
return;
};
// Display how many attached emails are embedded within
// this one:
const num_attached = email.getNumAttachedMessages();
std.debug.print("numAttached = {d}\n", .{num_attached});
// Get the 1st attached message.
const email2 = try chilkat.Email.init();
defer email2.deinit();
if (email.getAttachedEmail(0, email2)) {
// Display the subject, From, and a header field...
std.debug.print("{s}\n", .{try email2.getSubject(alloc)});
std.debug.print("{s}\n", .{try email2.getFrom(alloc)});
std.debug.print("{s}\n", .{try email2.getHeaderField(alloc, "X-SOMETHING")});
} else |_| {}
}