Zig
Zig
Get a Cc Recipient's Name Only
See more Email Object Examples
Demonstrates the Chilkat Email.GetCcName method, which returns only the friendly-name part (not the address) of the Nth carbon-copy recipient. The index is zero-based. This example adds two Cc recipients and prints each one's display name.
Background: A recipient combines a display name with an address, such as
Jane Doe <jane@example.com>. GetCcName returns just the Jane Doe portion, which is handy for showing a friendly label in a UI. The name is optional free-form text, so it may be empty — when it is, fall back to the address from GetCcAddr.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// Demonstrates the GetCcName method, which returns only the friendly-name part (not the
// address) of the Nth carbon-copy recipient. The index is zero-based.
const email = try chilkat.Email.init();
defer email.deinit();
email.setSubject("GetCcName example");
email.addCC("Joe Smith", "joe@example.com") catch {};
email.addCC("Jane Doe", "jane@example.com") catch {};
const n = email.getNumCC();
var i: i32 = 0;
i = 0;
while (i < n) : (i += 1) {
std.debug.print("Cc {d} name: {s}\n", .{ i, try email.getCcName(alloc, i) });
}
}