Sample code for 30+ languages & platforms
Visual Basic 6.0

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 Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
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).

Dim mailman As New ChilkatMailMan

'  Build the email to render.
Dim email As New ChilkatEmail
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.
Dim sbMime As New ChilkatStringBuilder

success = mailman.RenderToMimeSb(email,sbMime)
If (success = 0) Then
    Debug.Print mailman.LastErrorText
    Exit Sub
End If

Debug.Print sbMime.GetAsString()