PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkMime.pb"
Procedure ChilkatExample()
success.i = 0
mime.i = CkMime::ckCreate()
If mime.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Create a multipart/mixed entity.
success = CkMime::ckNewMultipartMixed(mime)
If success = 0
Debug CkMime::ckLastErrorText(mime)
CkMime::ckDispose(mime)
ProcedureReturn
EndIf
; Boundary is the raw boundary token, without surrounding quotation marks. Chilkat quotes it
; automatically in the serialized header when required.
CkMime::setCkBoundary(mime, "example-boundary")
; UseMmDescription controls whether the conventional preamble text
; "This is a multi-part message in MIME format." is emitted. The default is 0.
CkMime::setCkUseMmDescription(mime, 1)
; Add a simple part so the multipart has content.
part.i = CkMime::ckCreate()
If part.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkMime::ckSetBodyFromPlainText(part,"First part.")
If success = 0
Debug CkMime::ckLastErrorText(part)
CkMime::ckDispose(mime)
CkMime::ckDispose(part)
ProcedureReturn
EndIf
success = CkMime::ckAppendPart(mime,part)
If success = 0
Debug CkMime::ckLastErrorText(mime)
CkMime::ckDispose(mime)
CkMime::ckDispose(part)
ProcedureReturn
EndIf
Debug "Boundary = " + CkMime::ckBoundary(mime)
mimeStr.s = CkMime::ckGetMime(mime)
If CkMime::ckLastMethodSuccess(mime) = 0
Debug CkMime::ckLastErrorText(mime)
CkMime::ckDispose(mime)
CkMime::ckDispose(part)
ProcedureReturn
EndIf
Debug mimeStr
CkMime::ckDispose(mime)
CkMime::ckDispose(part)
ProcedureReturn
EndProcedure