Sample code for 30+ languages & platforms
Xojo Plugin

Get an Email's MIME into a StringBuilder

See more Email Object Examples

Demonstrates the Chilkat Email.GetMimeSb method, which returns the email as MIME text (header, body or bodies, related items, and all attachments) by appending it to a StringBuilder object. This example builds a message and appends its MIME to a StringBuilder.

Background: This is a StringBuilder-based alternative to GetMime, which returns a plain string. Writing into a StringBuilder is more efficient when the MIME is large or when you intend to further manipulate it — searching, replacing, or accumulating additional text — without creating many intermediate string copies.

Chilkat Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

//  Demonstrates the GetMimeSb method, which returns the email as MIME text (headers, bodies,
//  related items, and attachments), appending it to a StringBuilder object.

Dim email As New Chilkat.Email
email.Subject = "GetMimeSb example"
email.From = "alice@example.com"
success = email.AddTo("Bob","bob@example.com")
email.Body = "Hello!"

//  Append the complete MIME to a StringBuilder.
Dim sbMime As New Chilkat.StringBuilder
success = email.GetMimeSb(sbMime)
If (success = False) Then
    System.DebugLog(email.LastErrorText)
    Return
End If

System.DebugLog(sbMime.GetAsString())