Zig
Zig
MIME Multipart Boundary and Preamble Properties
See more MIME Examples
Demonstrates the Boundary property, which gets or sets the raw boundary token of a multipart entity (without surrounding quotation marks), and UseMmDescription, which controls whether the conventional preamble text is emitted when serializing a multipart entity.
Background. A multipart boundary separates the constituent parts. Chilkat quotes the token automatically in the header when required. The preamble is ignored by MIME-aware readers and is off by default.
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 mime = try chilkat.Mime.init();
defer mime.deinit();
// Create a multipart/mixed entity.
mime.newMultipartMixed() catch {
std.debug.print("{s}\n", .{try mime.getLastErrorText(alloc)});
return;
};
// Boundary is the raw boundary token, without surrounding quotation marks. Chilkat quotes it
// automatically in the serialized header when required.
mime.setBoundary("example-boundary");
// UseMmDescription controls whether the conventional preamble text
// "This is a multi-part message in MIME format." is emitted. The default is false.
mime.setUseMmDescription(true);
// Add a simple part so the multipart has content.
const part = try chilkat.Mime.init();
defer part.deinit();
part.setBodyFromPlainText("First part.") catch {
std.debug.print("{s}\n", .{try part.getLastErrorText(alloc)});
return;
};
mime.appendPart(part) catch {
std.debug.print("{s}\n", .{try mime.getLastErrorText(alloc)});
return;
};
std.debug.print("Boundary = {s}\n", .{try mime.getBoundary(alloc)});
const mime_str = mime.getMime(alloc) catch {
std.debug.print("{s}\n", .{try mime.getLastErrorText(alloc)});
return;
};
std.debug.print("{s}\n", .{mime_str});
}