Lua
Lua
Render an Email to MIME in a StringBuilder
See more SMTP Examples
Demonstrates the Chilkat MailMan.RenderToMimeSb method, which renders an Email object as MIME text and appends the result to a StringBuilder, without sending the email. This example renders a message into a StringBuilder and prints it.
Background: This is the
StringBuilder version of RenderToMime. Appending into a StringBuilder is more efficient when the MIME is large or when you plan to further inspect or manipulate it — searching, replacing, or accumulating additional text — without creating extra intermediate string copies.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- Demonstrates the MailMan.RenderToMimeSb method, which renders an Email object as MIME text
-- and appends the result to a StringBuilder (without sending the email).
local mailman = chilkat.MailMan.new()
-- Build the email to render.
local email = chilkat.Email.new()
email.subject = "Rendered email"
email.from = "alice@example.com"
email:add_to("Bob", "bob@example.com")
email.body = "This message is rendered to MIME in a StringBuilder."
-- Render the MIME into a StringBuilder.
local sbMime = chilkat.StringBuilder.new()
local success = mailman:render_to_mime_sb(email, sbMime)
if not success then
print(mailman.last_error_text)
return
end
print(sbMime:get_as_string())