Sample code for 30+ languages & platforms
Classic ASP

Render an Email to MIME Bytes in a BinData

See more SMTP Examples

Demonstrates the Chilkat MailMan.RenderToMimeBd method, which renders an Email object as MIME bytes and appends the result to a BinData, without sending the email. This example renders a message into a BinData and prints the byte count.

Background: This is the binary version of RenderToMime. A BinData holds raw bytes, which is the right container when you want the rendered MIME as binary — to write it directly to a file or socket, hash it, or hand it to another API expecting a byte buffer — rather than as text.

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.RenderToMimeBd method, which renders an Email object as MIME
'  bytes and appends the result to a BinData (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 bytes in a BinData."

'  Render the MIME into a BinData.
set bdMime = Server.CreateObject("Chilkat.BinData")

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

Response.Write "<pre>" & Server.HTMLEncode( "Rendered MIME size (bytes) = " & bdMime.NumBytes) & "</pre>"

%>
</body>
</html>