DataFlex
DataFlex
Convert a MIME Entity to multipart/mixed
See more MIME Examples
Demonstrates the Chilkat Mime.ConvertToMultipartMixed method, which wraps the current entity in a new outer multipart/mixed, making the original the first child. It takes no arguments.
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 how you turn an existing single-part message into one that can hold attachments — rather than rebuilding it, you wrap it, and its content becomes the first child of a new
multipart/mixed. Message-level and custom headers are carried onto the new outer entity so the message identity is preserved. Afterward, AppendPartFromFile adds attachments beside the original body.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMime
String sTemp1
Integer iTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatMime)) To hoMime
If (Not(IsComObjectCreated(hoMime))) Begin
Send CreateComObject of hoMime
End
Get ComLoadMimeFile Of hoMime "qa_data/message.eml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// Wrap the current entity in a new outer multipart/mixed entity. The original entity becomes the
// first child, which is what you do to add attachments to an existing single-part message.
Get ComConvertToMultipartMixed Of hoMime To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// Now attachments can be appended alongside the original content.
Get ComAppendPartFromFile Of hoMime "qa_data/report.pdf" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComNumParts Of hoMime To iTemp1
Showln "Number of parts: " iTemp1
End_Procedure