DataFlex
DataFlex
Add File Attachments to an Email
Demonstrates how to add one or more file attachments to an email.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoEmail
String sContentType
String sTemp1
Boolean bTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "This is a test"
Set ComBody Of hoEmail To "This is a test"
Set ComFrom Of hoEmail To "support@chilkatsoft.com"
Get ComAddTo Of hoEmail "Chilkat Admin" "admin@chilkatsoft.com" To iSuccess
// To add file attachments to an email, call AddFileAttachment
// once for each file to be attached. The method returns
// the content-type of the attachment if successful, otherwise
// returns cknull
Get ComAddFileAttachment Of hoEmail "something.pdf" To sContentType
Get ComLastMethodSuccess Of hoEmail To bTemp1
If (bTemp1 <> True) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComAddFileAttachment Of hoEmail "something.xml" To sContentType
Get ComLastMethodSuccess Of hoEmail To bTemp1
If (bTemp1 <> True) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComAddFileAttachment Of hoEmail "something.zip" To sContentType
Get ComLastMethodSuccess Of hoEmail To bTemp1
If (bTemp1 <> True) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComSaveEml Of hoEmail "email.eml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Saved EML!"
End_Procedure