VBScript
VBScript
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 VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
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 = CreateObject("Chilkat.Mime")
success = mime.SetBodyFromPlainText("Hello, this is the message body.")
If (success = 0) Then
outFile.WriteLine(mime.LastErrorText)
WScript.Quit
End If
' Append the serialized MIME to a StringBuilder. Existing content is preserved.
set sb = CreateObject("Chilkat.StringBuilder")
success = mime.GetMimeSb(sb)
If (success = 0) Then
outFile.WriteLine(mime.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(sb.GetAsString())
outFile.Close