Sample code for 30+ languages & platforms
Xojo Plugin

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 Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

//  Demonstrates the MailMan.RenderToMimeBd method, which renders an Email object as MIME
//  bytes and appends the result to a BinData (without sending the email).

Dim mailman As New Chilkat.MailMan

//  Build the email to render.
Dim email As New 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.
Dim bdMime As New Chilkat.BinData

success = mailman.RenderToMimeBd(email,bdMime)
If (success = False) Then
    System.DebugLog(mailman.LastErrorText)
    Return
End If

System.DebugLog("Rendered MIME size (bytes) = " + Str(bdMime.NumBytes))