See also:
Running a C# script
An overview of scripting in Email Parser
From: test@example.com To: example@example.com Subject: Weather report Temperature: 22.1 Temperature: 12.3 Temperature: -1.7 Temperature: 5.8
And after parsing the temperature values with a regular expression we run a script (once for each value) where we check if the temperature is above or below zero. Depending on the result of the script we export the captured text to one Google spreadsheet or another
The script we use creates a new field called “is_above_zero” that we will use later in the conditional action.
using System; using System.Text; using System.IO; using System.Net.Mail; using System.Net.NetworkInformation; using System.Collections.Specialized; using EmailParserBackendApi.ScriptingInterface; public class MyAction : ScriptBasedAction { public override bool Run(MailMessage email, NameValueCollection fields) { // Check if the database server is online if (float.Parse(fields["Temperature"])>0) fields.Add("is_above_zero", "yes"); else fields.Add("is_above_zero", "no"); return (true); } }
In Email Parser, this script is placed under an action of type “Run a C# script”
Then we evaluate the result of the script in the next action:
And export to the corresponding spreadhseet the temperature value:
When an email is received Email Parser runs all the items and produces the following output: