Email Parser

Extract data from incoming emails and automate your workflow

MENUMENU
DOCUMENTATION TOPICSDOCUMENTATION TOPICS

Creating a custom action with a script

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 specific actions for the most common tasks but sometimes a very specific action need to be done for the emails. For this purpose script actions and theĀ  process that runs external program are provided.

To create your own script action you need to implement the function Run() as it is shown below:

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);
	}
}