This shows you the differences between two versions of the page.
— |
reference:spamrules_statement_zipcount [2018/11/14 10:45] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Spam Filter Rules: ZipCount====== | ||
+ | ^Statement |ZipCount | | ||
+ | ^Version |6.7+ | | ||
+ | ^Purpose |Enables the script to obtain the number of files contained in a ZIP attachment | | ||
+ | The **ZipCount** statement requires a message section number and variable name, in the format | ||
+ | ZipCount <message section number> <variable name> | ||
+ | |||
+ | * If the message section doesn't contain a ZIP attachment, then the variable will be set to '-1' | ||
+ | * If the message section does contain a ZIP attachment, then the variable will be set to the number of files in the ZIP attachment | ||
+ | |||
+ | =====Example===== | ||
+ | The following example will iterate through the MIME sections and get the ZIP file content count into a variable ${zipcount} | ||
+ | <code> | ||
+ | ForEach MimeSection SectionInfo | ||
+ | IfMatch ${SectionInfo} "/^(\d+):([\d\. ]*):([^:]*)/" | ||
+ | ${SectionId} = ${1} | ||
+ | ${SectionType} = ${3} | ||
+ | If ${SectionType} == "application/zip" | ||
+ | ZipCount ${SectionId} zipcount | ||
+ | EndIf | ||
+ | EndIf | ||
+ | EndForEach | ||
+ | </code> |