Sample code for 30+ languages & platforms
Classic ASP

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 Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Demonstrates the MailMan.RenderToMimeSb method, which renders an Email object as MIME text
'  and appends the result to a StringBuilder (without sending the email).

set mailman = Server.CreateObject("Chilkat.MailMan")

'  Build the email to render.
set email = Server.CreateObject("Chilkat.Email")
email.Subject = "Rendered email"
email.From = "alice@example.com"
success = email.AddTo("Bob","bob@example.com")
email.Body = "This message is rendered to MIME in a StringBuilder."

'  Render the MIME into a StringBuilder.
set sbMime = Server.CreateObject("Chilkat.StringBuilder")

success = mailman.RenderToMimeSb(email,sbMime)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( mailman.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( sbMime.GetAsString()) & "</pre>"

%>
</body>
</html>