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.
Post here if you experience problems or get unexpected errors.
Hi guys, i'm running purchased version of EmailParser v4.5, getting the error "Error. An invalid character was found in the mail header", i believe the issue is caused by the "TO" field being "undisclosed-recipients:". Is there any way I can validate the "TO" field value in custom script? or is this validation done internally by the application?

Below is the parser log with the Run Script process code. Please help.
Connecting to the IMAP server at imap.gmail.com

Accessing folder INBOX

Getting email list

1 new email

Downloading email 1 of 1

Disconnecting



Processing email 1 of 1
From: emailaddress@email.com
To: undisclosed-recipients:
Subject: Shipment Notification: [OK to MA]


email content

The email contains the following fields:

Subject Shipment Notification: [OK to MA]
From emailaddress@email.com
To undisclosed-recipients:
Body Body___________________ ...check email history->this email->fields for the complete value
Body_HTML
CC empty
BCC empty
DateTimeSent 2018-02-13 15:39:06
DateTimeReceived 2018-02-13 15:40:37
········ Running Milton Capture Trip ID

The parser produced the following results:

TripID empty
Re-format Dates 20180213154037
········ Running Milton Attachments

Saving attachments:

Attachment saved to c:\email\milton\~WRD392.jpg

The following fields will be available for the next automated processes:

Attachment c:\email\milton\~WRD392.jpg
········ Running Run script

Error. An invalid character was found in the mail header: ':'..
// This is a template for a script action.
// Check out:
// http://www.AutomatedEmailParser.com/documentation.php?go=topic304
// for further information and examples

using System;
using System.Text;
using System.IO;
using System.Net.Mail;
using System.Collections.Specialized;
using EmailParser.Logic.ScriptingInterface;

public class MyAction : ScriptBasedAutomatedProcess
{
public override bool Run(MailMessage email, NameValueCollection fields)
{
Random r = new Random();
int rInt = r.Next(0,1000);

// Check that we have some attachments saved
if (fields.GetValues("Attachment") == null)
{
Print("This email has no attachments");
return (false);
}

// For each value stored in the attachment field
// create a new value with the TripId + Re-format Date + Random Int
// This value will be used to rename the physical file on the folder (Renamed by command line automation process)
foreach (string attachment_path in fields.GetValues("Attachment"))
{
string actualFileName = Path.GetFileName(attachment_path);
rInt = r.Next(0,1000);
fields.Add("attachment_filenames", fields["TripID"] + fields["Re-format Dates"] + rInt.ToString());
fields.Add("actualFileName", actualFileName);

Print(actualFileName);
}

return(true);
}
}
Hi,

This is a bug of the version 4.5 and I think (although I am not completely sure) it was addressed in version 4.6. If you update Email Parser it will probably work.

Note that 4.6 uses a slightly different namespace for scripts. You will need to replace this:
using EmailParser.Logic.ScriptingInterface;

public class MyAction : ScriptBasedAutomatedProcess
with this:
using EmailParserBackend.ScriptingInterface;

public class MyAction : ScriptBasedAction
Please, post here again if the problem persists.