email parsing automation

Email Parser

Extract data from emails and automate your workflow

The forum is now read only. Please, go to the the main Email Parser website if you need help.
Need help configuring the program? Have any questions regarding its use?
Hallo!

Could you please help me to find a solution for the following problem:

Sometimes I get an email with the following examples in the body:

Word 1, Word 1

or
Word 2, Word 2

or
Word 3, Word 1

or
Word 3, Word 2

I have a "field name" for Word x, Word y , a "field name" for Word x and a "field name" for Word y.

Now I need a comparator and replacer to get the following result:
"If Word x is the same as Word y, replace Word x with a space character"
"If Word x is not the same as Word y, do not replace Word x"

to get an output result like:
Word x =
Word y = Word 1

or
Word x = Word 3
Word y = Word 1

Which input do I have to do in the field name to get my requested output result?

Thank you for your help!

buxi
Hi Buxi,

This seems to be something that must done via scripting. I hope this helps:

using System;
using System.Text;
using System.IO;
using System.Collections.Generic;
using EmailParserBackend.ScriptingInterface;

public class MyScriptBasedEmailParser : ScriptBasedParser // do not modify class name
{
// Modify this method to implement your own text capturing
public override List<string> ExtractTextFrom(string input_text)
{
// This will hold the result of this script
List<string> captured_values = new List<string>();

// Separate the line in words, it is expected there are two and
// are separated by a comma
string[] words_in_line = input_text.Split(new char[]{','});

if(words_in_line.Length!=2)
{
Print("Error. We exprected two words!");
return(captured_values);
}

// Remove any white space character before or after the actual word
string word_x = words_in_line[0].Trim();
string word_y = words_in_line[1].Trim();

// If Word x is the same as Word y, replace Word x with a space character
if(word_x.Equals(word_y))
word_x=" ";

// done, return the values back to Email Parser
captured_values.Add(word_x);
return (captured_values);
}
}
Attachments
capture_words.jpg
capture_words.jpg (235.07KiB)Viewed 933 times
GREAT!

It works! Thank you very much! :)
Script for Email Parser 4.5:
using System;
using System.Text;
using System.Collections.Generic;
using EmailParser.Logic.ScriptingInterface;

public class MyScriptBasedEmailParser : ScriptBasedParser
{
//
// Modify this method to implement your own text capture
//
public override List<string> ExtractTextFrom(string input_text)
{
List<string> captured_values = new List<string>();

// Separate the line in words, it is expected there are two and
// are separated by a comma
string[] words_in_line = input_text.Split(new char[]{','});

if(words_in_line.Length!=2)
{
Print("Error. We exprected two words!");
return(captured_values);
}

// Remove any white space character before or after the actual word
string word_x = words_in_line[1].Trim();
string word_y = words_in_line[0].Trim();

// If Word x is the same as Word y, replace Word x with a space character
if(word_x.Equals(word_y))
word_x="";

// done, return the values back to Email Parser
captured_values.Add(word_x);
return (captured_values);
}
}
Script for Email Parser 4.6:
using System;
using System.Text;
using System.IO;
using System.Collections.Generic;
using EmailParserBackend.ScriptingInterface;

public class MyScriptBasedEmailParser : ScriptBasedParser
{
//
// Modify this method to implement your own text capture
//
public override List<string> ExtractTextFrom(string input_text)
{
List<string> captured_values = new List<string>();

// Separate the line in words, it is expected there are two and
// are separated by a comma
string[] words_in_line = input_text.Split(new char[]{','});

if(words_in_line.Length!=2)
{
Print("Error. We exprected two words!");
return(captured_values);
}

// Remove any white space character before or after the actual word
string word_x = words_in_line[1].Trim();
string word_y = words_in_line[0].Trim();

// If Word x is the same as Word y, replace Word x with a space character
if(word_x.Equals(word_y))
word_x="";

// done, return the values back to Email Parser
captured_values.Add(word_x);
return (captured_values);
}
}