Creating a custom action with a script

👉This action is only supported in the Windows App

See also: Email Parser scripting SDK Capturing text with scripts Using scripts to filter emails Example – Basic use of a script in an action

 

  Email Parser provides actions for the most common tasks (SQL, Excel, Command line, Web API¬†…) but if you need to perform something different you can use C# to create your own action. A script action is the implementation of the Run() method as it is shown below. This method takes the following parameters:  
using System;
using System.Text;
using System.IO;
using System.Net.Mail;
using System.Net.NetworkInformation;
using System.Collections.Specialized;
using EmailParserBackend.ScriptingInterface;
 
public class MyAction : ScriptBasedAction
{
	public override bool Run(MailMessage email, NameValueCollection fields)
	{
        // Check if the database server is online
        string database_server_ip_address = "192.168.0.45";
        Ping pingSender = new Ping();
        PingReply reply = pingSender.Send(database_server_ip_address);
        if (reply.Status == IPStatus.Success)
            fields.Add("is_online_db_server", "yes");
        else
            fields.Add("is_online_db_server", "no");
 
        return (true);
	}
}