DataFlex
DataFlex
Unzip an Email's Zip Attachments
See more Email Object Examples
Demonstrates the Chilkat Email.UnzipAttachments method, which unzips and replaces any Zip file attachments with their expanded contents. For example, if an email contains a single Zip holding three files, that Zip attachment is replaced by the three files as individual attachments. This example loads an email and expands its Zip attachments.
Background: Senders often bundle several files into one
.zip to keep a message tidy or to compress large content. UnzipAttachments reverses that automatically, so downstream processing can work with the individual files directly rather than having to detect, extract, and re-inject archive contents. It is the inverse of ZipAttachments.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoEmail
String sTemp1
Integer iTemp1
Move False To iSuccess
// Demonstrates the UnzipAttachments method, which unzips and replaces any Zip file
// attachments with their expanded contents. For example, a single Zip containing 3 files
// is replaced by those 3 files as individual attachments.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Get ComLoadEml Of hoEmail "qa_data/eml/with_zip_attachment.eml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComNumAttachments Of hoEmail To iTemp1
Showln "NumAttachments before = " iTemp1
// Expand any Zip attachments in place.
Get ComUnzipAttachments Of hoEmail To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComNumAttachments Of hoEmail To iTemp1
Showln "NumAttachments after = " iTemp1
// Note: The path "qa_data/..." is a relative local filesystem path,
// relative to the current working directory of the running application.
End_Procedure