Email Filter Scripts for Customer Portal

Allegra can create items and comments on items from emails. The system itself tries to generally prevent email loops. In addition, it is possible to scan emails for specific content and suppress the creation of unwanted items.

Manage email filter scripts

To manage email filtering scripts, go to the Administration perspective > Customize > Scripts. There you will find at least three scripts:

  • A parameter record EmailSubjectRejectRegexps.

  • A parameter record EmailBodyCutRegexps.

  • One parameter record EmailAttachmentRemoveRegexps

These records are not scripts in the true sense, but are used as parameters for a filtering function built into the system. They will be explained in the following.

Parameter record EmailSubjectRejectRegexps

This record must have the same name and contains a number of lines with regular expressions. If at least one of these expressions is found in the subject line of an email, the email is ignored and no process is created from it. For more information on regular expressions, see example.

https://wiki.selfhtml.org/wiki/Regulärer_Ausdruck.

The expressions are case-insensitive. Comment lines begin with a double cross “#”. One regular expression may be specified per line.

# comment
automatic answer
out of.*?office
out of.*?house
Automatic answer
out of house

If you rename this record, it becomes inactive. This can lead to unwanted email loops.

Parameter record EmailBodyCutRegexps

This record must have the same name and contains a number of regular expression lines. The part of the body of an email to which the expression applies is removed. For more information on regular expressions, see example.

https://wiki.selfhtml.org/wiki/Regulärer_Ausdruck.

The expressions are case-insensitive and ignore line breaks. Comment lines begin with a double cross “#”. One regular expression may be specified per line. In the following example, the disclaimer text at the end of an email is removed if it begins with the text “This email may contain confidential” and ends with the text “We thank you for your coitem”.

# comment
This\s*email\s*may\s*contain\s*confidential.*?We\s*thank\s*you\s*for\s*your\s*coitem\.

If you rename the record, it becomes inactive.

Parameter record EmailAttachmentRemoveRegexps

This record must keep the same name and contains a number of regular expression lines. Repeated embedded attachments such as logos, signature images, etc. should not normally be stored as attachments. Allegra provides three ways to filter attachments or references:

  • by file name

  • references to attachments

  • hashcode of an attachment

You define the patterns respectively after the lines with the markers “#fileNames:”, “#referencePatterns:” and “#fileHashes:”. If the system finds an attachment whose filename matches a regular expression, the attachment is not saved. The filename patterns are case-sensitive.

To also delete the references to image attachments within the main body of the email, type after the “#referencePatterns:” marker to specify reference patterns. The $cid part is dynamically removed with the current cid value. Each line below should contain a regular expression until the next marker.

It may be that an email client changes the name of an embedded file to a generic name. In this case, you cannot retrieve the file by name. This is where the “#fileHashes:” function comes in to help you. After the “#fileHashes:” marker, you can create a list with one hash code per line for each file that should not be added as attachment.

Note

You can retrieve a hash for a file when editing an item with that attachment by right-clicking on the attachment of the item and selecting “File Hash Code”.

# comment
#fileNamePatterns:
track.*\.png
#referencePatterns:
<a href=\"#\".*?><img.*?src=\"cid:$cid\".*?><\/a>
#fileHashes:
#mailLogo
327623B4C0F43950325B56353D431EBB
#tracklogo
B01CAF8D877E5551AA694897A4C29C36
#reportLogo
5053A46D4188920C77578FE8B75D