DataFlex
DataFlex
Create a multipart/mixed MIME Entity
See more MIME Examples
Demonstrates the Chilkat Mime.NewMultipartMixed method, which initializes the object as an empty multipart/mixed entity, clearing any existing content. It takes no arguments; child parts are then appended.
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:
multipart/mixed is the container for independent parts shown one after another — the classic "message body plus attachments" layout. Each child is its own distinct content, unlike multipart/alternative (competing renderings of the same thing) or multipart/related (a part and its embedded resources). Start here, then AppendPart a body and AppendPartFromFile the attachments.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMime
Variant vBodyPart
Handle hoBodyPart
String sTemp1
Integer iTemp1
Move False To iSuccess
// Demonstrates the Mime.NewMultipartMixed method, which initializes the object as an empty
// multipart/mixed entity, clearing any existing headers, body, and child parts. It takes no
// arguments.
Get Create (RefClass(cComChilkatMime)) To hoMime
If (Not(IsComObjectCreated(hoMime))) Begin
Send CreateComObject of hoMime
End
Get ComNewMultipartMixed Of hoMime To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// Append child parts. multipart/mixed is the container for a message body plus attachments.
Get Create (RefClass(cComChilkatMime)) To hoBodyPart
If (Not(IsComObjectCreated(hoBodyPart))) Begin
Send CreateComObject of hoBodyPart
End
Get ComSetBodyFromPlainText Of hoBodyPart "See the attached report." To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoBodyPart To sTemp1
Showln sTemp1
Procedure_Return
End
Get pvComObject of hoBodyPart to vBodyPart
Get ComAppendPart Of hoMime vBodyPart To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
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