PureBasic
PureBasic
Serialize MIME to a String
See more MIME Examples
Demonstrates the Chilkat Mime.GetMime method, which serializes and returns the complete MIME entity — headers, body, multipart boundaries, and all descendants — as a string. It takes no arguments.
Background: This produces the finished MIME text ready to send, store, or hand to another component — the inverse of loading. The whole tree is emitted, including generated multipart boundaries. Because it returns a string, it is best for text-safe content; when the body may contain raw binary bytes, serialize with
GetMimeBd to a BinData instead so nothing is altered.Chilkat PureBasic Downloads
IncludeFile "CkMime.pb"
Procedure ChilkatExample()
success.i = 0
; Demonstrates the Mime.GetMime method, which serializes and returns the complete MIME entity
; (headers, body, multipart boundaries, and all descendants) as a string. It takes no
; arguments.
mime.i = CkMime::ckCreate()
If mime.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Build a simple MIME entity.
success = CkMime::ckSetBodyFromPlainText(mime,"Hello, this is the message body.")
If success = 0
Debug CkMime::ckLastErrorText(mime)
CkMime::ckDispose(mime)
ProcedureReturn
EndIf
; Serialize it to a string.
mimeText.s = CkMime::ckGetMime(mime)
If CkMime::ckLastMethodSuccess(mime) = 0
Debug CkMime::ckLastErrorText(mime)
CkMime::ckDispose(mime)
ProcedureReturn
EndIf
Debug mimeText
CkMime::ckDispose(mime)
ProcedureReturn
EndProcedure