I slightly modified the
Alias_Del template and added a new
Address_Del template to make it more generalized. The Address_Del template is called from the Alias_Del template. The
Alias_Del template is now following:
Code |
---|
Hello %OFromFName,
%Cursor
%ODateEn, %OTimeLongEn, you wrote:
%Quotes
--
Best regards,
%FromName
%SetHeader('To','%OFromName <%OFromAddr>')%-
%SetHeader('Cc','')%-
%_CC='%OToList, %OCCList'%-
%_RE1="(?ism)(.*(,\s)+)*(.*alias1@domain1\.com(>)?(,\s)?)(.*)"%-
%QT(Address_Del, "%_RE1")%-
%_RE1="(?ism)(.*(,\s)+)*(.*alias2@domain2\.com(>)?(,\s)?)(.*)"%-
%QT(Address_Del, "%_RE1")%-
%_RE1="(?ism)(.*(,\s)+)*(.*alias3@domain3\.pl(>)?(,\s)?)(.*)"%-
%QT(Address_Del, "%_RE1")%-
%SetHeader('Cc','%_CC')%- |
And here is the
Address_Del template:
Code |
---|
%_CC(%ReplaceRegExp("%_1", "", "%_CC", 3))%-
%SetpattRegExp="(?ismU)(.*)(,\s)*$"%-
%RegExpBlindMatch(%_CC)%-
%_CC(%SubPatt(1))%- |
Perhaps it will be easier for you to modify the templates yourself if I explain the meaning of each entry.
The initial lines in the
Alias_Del template up to the
%FromName macro are a copy of the default response template from The Bat! account. You can modify it freely because it formats only the content of the response without interfering with the recipient lists.
The next macro
%SetHeader('To','%OFromName <%OFromAddr>') defines the contents of the "
To" field in the response. I assume that only the sender of the original message will appear here. The
%SetHeader('Cc','') macro is used to clear the "
Cc" field of the response being created. The remaining recipients appear in the "To" and "Cc" fields of the original message. They are collected in a common list, which is the value of the
%_CC variable (macro
%_CC='%OToList, %OCCList').
Next comes the definition of a regular expression, which will be stored in the %_RE1 variable. The individual elements of this expression can be explained as follows:
(?ism) - these are search options used in regular expressions (e.g. case insensitive, multi-line search, etc.)
(.*(,\s)+)* - text preceding the searched e-mail address, i.e. a string of arbitrary characters symbolized by "
.*", followed by one comma with a space symbolized by
(,\s)+(.*alias1@domain1\.com(>)?(,\s)?) - the address you are looking for, preceded by any number of characters and ending with the optional ">" character, i.e.
(>)?, and a comma with a space
(,\ s)?.
(.*) - any text that may follow the searched address.
The regular expression defined in this way is sent to the
Address_Del template as an argument:
%QT(Address_Del, "%_RE1"). In this template, the list of recipients contained in the
%_CC variable is properly processed. First, the requested address sent to the template as an argument is removed and
%ReplaceRegExp("%_1", "", "%_CC", 3) is used to do this. This macro looks up the requested address in the
%_CC variable based on the regular expression provided and replaces it with the empty string
"". Then the value of the variable is modified and from that moment on it no longer contains the address we are looking for.
It may happen that a "
comma,space" pair remains at the end of the list of recipients and three more macros are used to optionally remove it:
%SetpattRegExp="(?ismU)(.*)(,\s)*$"%-%RegExpBlindMatch(%_CC)%-%_CC(%SubPatt(1))%-The
Address_Del template
is called three times from the
Alias_Del template. Each call is preceded by an appropriate definition of the
%_RE1 variable, in which the address to be removed should be placed. Finally, the "Cc" field in the created response is modified, giving it the value of the
%_CC variable - macro
%SetHeader('Cc','%_CC').