DataFlex
DataFlex
Set the Email Body from a BinData
See more Email Object Examples
Demonstrates the Chilkat Email.SetBodyBd method, which sets the main email body from the binary data in a BinData object. The second argument is the MIME Content-Type, the third is the disposition (may be empty, inline, or attachment), and the fourth is the filename. This example loads HTML content into a BinData and sets it as the body.
Background:
SetBodyBd gives low-level control over the body when you already have its bytes and want to specify the exact Content-Type and MIME disposition yourself. It suits content that is generated or stored as binary — for example an EDI payload, a pre-rendered HTML fragment, or any custom content type — where the convenience of SetHtmlBody / SetTextBody does not apply.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoEmail
Variant vBd
Handle hoBd
String sTemp1
Boolean bTemp1
Move False To iSuccess
// Demonstrates the SetBodyBd method, which sets the main email body from the binary data in
// a BinData object. The second argument is the MIME Content-Type, the third is the
// disposition (may be empty, "inline", or "attachment"), and the fourth is the filename.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "Body from BinData"
// Load the body content from a file into a BinData object.
Get Create (RefClass(cComChilkatBinData)) To hoBd
If (Not(IsComObjectCreated(hoBd))) Begin
Send CreateComObject of hoBd
End
Get ComLoadFile Of hoBd "qa_data/html/body.html" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoBd To sTemp1
Showln sTemp1
Procedure_Return
End
// Set the main body from the binary data as text/html.
Get pvComObject of hoBd to vBd
Get ComSetBodyBd Of hoEmail vBd "text/html" "" "" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComHasHtmlBody Of hoEmail To bTemp1
Showln "HasHtmlBody: " bTemp1
// Note: The path "qa_data/html/body.html" is a relative local filesystem path,
// relative to the current working directory of the running application.
End_Procedure