Sample code for 30+ languages & platforms
VB.NET

MIME Multipart Boundary and Preamble Properties

See more MIME Examples

Demonstrates the Boundary property, which gets or sets the raw boundary token of a multipart entity (without surrounding quotation marks), and UseMmDescription, which controls whether the conventional preamble text is emitted when serializing a multipart entity.

Background. A multipart boundary separates the constituent parts. Chilkat quotes the token automatically in the header when required. The preamble is ignored by MIME-aware readers and is off by default.

Chilkat VB.NET Downloads

VB.NET
Dim success As Boolean = False

Dim mime As New Chilkat.Mime

'  Create a multipart/mixed entity.
success = mime.NewMultipartMixed()
If (success = False) Then
    Debug.WriteLine(mime.LastErrorText)
    Exit Sub
End If


'  Boundary is the raw boundary token, without surrounding quotation marks.  Chilkat quotes it
'  automatically in the serialized header when required.
mime.Boundary = "example-boundary"

'  UseMmDescription controls whether the conventional preamble text
'  "This is a multi-part message in MIME format." is emitted.  The default is False.
mime.UseMmDescription = True

'  Add a simple part so the multipart has content.
Dim part As New Chilkat.Mime
success = part.SetBodyFromPlainText("First part.")
If (success = False) Then
    Debug.WriteLine(part.LastErrorText)
    Exit Sub
End If

success = mime.AppendPart(part)
If (success = False) Then
    Debug.WriteLine(mime.LastErrorText)
    Exit Sub
End If


Debug.WriteLine("Boundary = " & mime.Boundary)

Dim mimeStr As String = mime.GetMime()
If (mime.LastMethodSuccess = False) Then
    Debug.WriteLine(mime.LastErrorText)
    Exit Sub
End If

Debug.WriteLine(mimeStr)