Macros are code blocks which are defined once (see also Mail Processing Ruleset generator Custom commands Custom macros and commands for all emails BEFORE processing:) and can then be used as often as desired in the custom commands.
Macros
•can be defined at any time and are globally valid.
•can only be used after they have been declared.
•cannot be re-declared, this means that if a macro with the same name already exists, it will not be overwritten.
•contain complete code blocks, i.e. they cannot be used as variables in functions.
•can be nested into each other.
•can be used any number of times.
•are read and expanded at compile time - i.e. when generating a new ruleset (see also Mail Processing Ruleset generator Save and Create ruleset).
•with incorrect syntax prevent the generation of a ruleset.
•with correct syntax, but which are not used, do not generate any code when generating the ruleset.
•may not contain any predefined functions.
Structure of a macro
<Name_des_Makros> = {
Codeblock
};
accessing a macro
$<Name_des_Makros>;
Example
Line |
Code |
---|---|
01 |
my_encrption = { |
02 |
if (smime_keys_avail()) { |
03 |
log(1,'S/MIME certificate available for recipient(s) $to'); |
04 |
if (encrypt_smime()) { |
05 |
log(1,'email successfully S/MIME encrypted'); |
06 |
} else { |
07 |
log(1,'e-mail could not be S/MIME encrypted'); |
08 |
} |
09 |
} else { |
10 |
log(1,'no S/MIME certificate available for recipient(s) $to'); |
12 |
} |
13 |
}; |
Accessing the macro (in any Custom commands, if necessary also nested in further macros):
Line |
Code |
---|---|
01 |
$my_encrption; |
02 |
deliver(); |