Sample code for 30+ languages & platforms
Zig

Email Body - Plain Text and/or HTML

Any given email may have a plain-text body, an HTML body, or both. The Body property will return the HTML body by default (if it exists) otherwise it will return the plain-text body. There are methods for checking to see if an email has a particular body (HasPlainTextBody and HasHtmlBody) and there are methods for getting a specific body: GetHtmlBody, GetPlainTextBody.

Chilkat Zig Downloads

Zig
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("something.eml") catch {
        std.debug.print("{s}\n", .{try email.getLastErrorText(alloc)});
        return;
    };

    // Display the default Body:
    std.debug.print("{s}\n", .{try email.getBody(alloc)});

    // If a plain-text body is present, display it:
    const b_text = email.hasPlainTextBody();
    if (b_text) {
        std.debug.print("{s}\n", .{try email.getPlainTextBody(alloc)});
    }

    // If an HTML body is present, display the HTML source:
    const b_html = email.hasHtmlBody();
    if (b_html) {
        std.debug.print("{s}\n", .{try email.getHtmlBody(alloc)});
    }
}