DataFlex Requires Chilkat v11.0.0+
DataFlex
Forward an email as an attachment
See more Email Object Examples
Attach the original Email to a new message as a message/rfc822 part. The recipient can open the attached email and read its original headers and body.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Variant vOriginal
Handle hoOriginal
Handle hoEmail
String sTemp1
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 "Sam Lee <sam@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 "Forwarded message"
Set ComBody Of hoEmail To "The original email is attached."
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 ComSaveEml Of hoEmail "forward-as-attachment.eml" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Saved forward-as-attachment.eml."
End_Procedure