Sample code for 30+ languages & platforms
Classic ASP

Serialize MIME to a StringBuilder

See more MIME Examples

Demonstrates the Chilkat Mime.GetMimeSb method, which serializes the complete MIME entity and appends it to a StringBuilder. The only argument is the StringBuilder; existing content is preserved.

Background: Serializing into a StringBuilder avoids creating a new string and is convenient when you are accumulating output or building a larger document. Because it appends, you can assemble several pieces in one buffer. As with GetMime, use the BinData form for content with arbitrary binary bytes.

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 Mime.GetMimeSb method, which serializes the complete MIME entity and appends
'  it to a StringBuilder.  The only argument is the StringBuilder.

set mime = Server.CreateObject("Chilkat.Mime")

success = mime.SetBodyFromPlainText("Hello, this is the message body.")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( mime.LastErrorText) & "</pre>"
    Response.End
End If

'  Append the serialized MIME to a StringBuilder.  Existing content is preserved.
set sb = Server.CreateObject("Chilkat.StringBuilder")
success = mime.GetMimeSb(sb)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( mime.LastErrorText) & "</pre>"
    Response.End
End If

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

%>
</body>
</html>