PureBasic
PureBasic
Load MIME from BinData
See more MIME Examples
Demonstrates the Chilkat Mime.LoadMimeBd method, which parses complete MIME bytes from a BinData and replaces the current MIME. The only argument is the BinData.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: This is the safest loader because it works on raw bytes: MIME can carry 8-bit content and even embedded NUL bytes that a text string would mangle, so loading from a
BinData preserves the message exactly. Prefer it whenever the input is binary or of uncertain encoding — a downloaded message, a file read as bytes — over the string-based loaders.Chilkat PureBasic Downloads
IncludeFile "CkBinData.pb"
IncludeFile "CkMime.pb"
Procedure ChilkatExample()
success.i = 0
; Demonstrates the Mime.LoadMimeBd method, which parses complete MIME bytes from a BinData and
; replaces the current MIME. The only argument is the BinData. This is the preferred loader
; when the MIME may contain arbitrary 8-bit or embedded NUL bytes.
bd.i = CkBinData::ckCreate()
If bd.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkBinData::ckLoadFile(bd,"qa_data/message.eml")
If success = 0
Debug CkBinData::ckLastErrorText(bd)
CkBinData::ckDispose(bd)
ProcedureReturn
EndIf
mime.i = CkMime::ckCreate()
If mime.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkMime::ckLoadMimeBd(mime,bd)
If success = 0
Debug CkMime::ckLastErrorText(mime)
CkBinData::ckDispose(bd)
CkMime::ckDispose(mime)
ProcedureReturn
EndIf
Debug "Content-Type: " + CkMime::ckContentType(mime)
CkBinData::ckDispose(bd)
CkMime::ckDispose(mime)
ProcedureReturn
EndProcedure