Sample code for 30+ languages & platforms
Zig

Create an Inline-Forward Email

See more Email Object Examples

Demonstrates the Chilkat Email.ToForward method, which creates an inline-forward email based on this email. The forward is returned in the argument, and the source email is not modified. The returned email can be edited — adding recipients, prepending a note — before sending. This example forwards a message and adds a recipient.

Background: An inline forward quotes the original message's content within the body of the new message — the familiar "---------- Forwarded message ----------" style — as opposed to attaching the original as a message/rfc822 part (which AttachEmail does). Chilkat assembles the quoted body and headers for you, leaving the new message ready to address and send.

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();

    // Demonstrates the ToForward method, which creates an inline-forward email based on this
    // email.  The forward is returned in the argument; the source email is not modified.

    const email = try chilkat.Email.init();
    defer email.deinit();
    email.setSubject("Quarterly results");
    email.setFrom("alice@example.com");
    email.addTo("Bob", "bob@example.com") catch {};
    email.setBody("Here are the quarterly results.");

    // Create an inline-forward email from this message.
    const fwd = try chilkat.Email.init();
    defer fwd.deinit();

    email.toForward(fwd) catch {
        std.debug.print("{s}\n", .{try email.getLastErrorText(alloc)});
        return;
    };

    // The forward can be edited to add recipients before sending.
    fwd.addTo("Carol", "carol@example.com") catch {};

    std.debug.print("{s}\n", .{try fwd.getMime(alloc)});
}