DataFlex Requires Chilkat v11.0.0+
DataFlex
Attach an existing EML as a message/rfc822 part
See more Email Object Examples
Load the saved message and attach a copy as a nested email. Recipients can open the nested headers, bodies, and attachments. Using an Email object avoids native byte-array differences across languages.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Variant vOriginal
Handle hoOriginal
Handle hoEmail
String sTemp1
Integer iTemp1
Move False To iSuccess
// Assumes Chilkat is unlocked. See Global Unlock Sample.
Get Create (RefClass(cComChilkatEmail)) To hoOriginal
If (Not(IsComObjectCreated(hoOriginal))) Begin
Send CreateComObject of hoOriginal
End
Get ComLoadEml Of hoOriginal "message.eml" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoOriginal To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComFrom Of hoEmail To "Workshop team <events@example.com>"
Get ComAddTo Of hoEmail "Alex Rivera" "alex@example.net" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Set ComSubject Of hoEmail To "Registration correspondence"
Set ComBody Of hoEmail To "The original message is attached for reference."
Get pvComObject of hoOriginal to vOriginal
Get ComAttachEmail Of hoEmail vOriginal To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComNumAttachedMessages Of hoEmail To iTemp1
Showln "Nested messages: " iTemp1
Get ComSaveEml Of hoEmail "correspondence.eml" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Saved correspondence.eml."
End_Procedure