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?
Hi,

I just wanted to take a minute to share my experience with other users out there considering a solution to their email parsing problem. My issue required parsing emails in my inbox and integrating the data into my Mailchimp list via the API. I had gotten several quotes for an entirely custom solution but it was cost prohibitive.

I found Email Parser through Google and downloaded it, and on the surface, it seemed to have the parsing needs handled. I contacted Carlos to see if he would be able to create script to connect with Mailchimp. For an extremely reasonable cost, he learned the API and was able to create a beautiful script for me that does exactly what I want. Throughout the process, he was polite and very capable, and very determined to get the job done to my specifications.

The end results worked exactly how I had hoped, and I couldn't be happier. I wouldn't hesitate to recommend Carlos and his software in the future. :)
Thanks for the nice post :)

I will copy here the script we made for this customer under our consultancy services we offer:

http://www.emailparser.com/professional-services

We of course have asked for his permission to post the script here. It subscribles people to a MailChimp group. I guess it may be useful for some customers or at least an example of what can be accomplished with the Email&Parser scripting capabilities.

[syntax=csharp]
using System;
using System.Text;
using System.IO;
using System.Net.Mail;
using System.Configuration;
using System.Collections.Specialized;
using System.Collections.Generic;
using EmailAndParser.ScriptingInterface;
using PerceptiveMCAPI;
using PerceptiveMCAPI.Types;
using PerceptiveMCAPI.Methods;


public class MyAction : ScriptBasedAction
{
public override bool Run(MailMessage email, NameValueCollection fields)
{
bool result = SubscribeToGroup(fields["first_name"],fields["last_name"],fields["To"],fields["date"]);

return (result);
}

public bool SubscribeToGroup(String first_name, String last_name, String email_address, String group_name)
{

String apikey ="xxxxxxxxx";

// input parameters, using default apikey
listsInput input = new listsInput(apikey);

// Execution
lists cmd = new lists(input);
listsOutput output = cmd.Execute();

listsResults list = null;


// Find the list "General serving"
foreach (listsResults list_item in output.result)
{
if (list_item.name == "General Serving")
{
list = list_item;
break;
}
}

if (list == null)
{
Print("The list General Serving does not exist in the MailChimp account");
return (false);
}

// Create the interest group with the date
listInterestGroupAddParms params3 = new listInterestGroupAddParms(apikey, list.id, group_name);
listInterestGroupAddInput input3 = new listInterestGroupAddInput(params3);
listInterestGroupAdd command3 = new listInterestGroupAdd(input3);

listInterestGroupAddOutput output3 = command3.Execute();

if (output3.result)
Print("The group " + group_name + " has been created");
else if (output3.api_ErrorMessages.Count > 0 && output3.api_ErrorMessages[0].code == "270")
{
Print("The group " + group_name + " already exists");
}
else
{
Print("Error. Could not create the group " + group_name);
return (false);
}

// Get the id of the group
listInterestGroupingsParms params4 = new listInterestGroupingsParms(apikey, list.id);
listInterestGroupingsInput input4 = new listInterestGroupingsInput(params4);
listInterestGroupings command4 = new listInterestGroupings(input4);

listInterestGroupingsOutput output4 = command4.Execute();


Int32 grouping_id = 0;
foreach(listInterestGroupingsResults group_item in output4.result)
{
if(group_item.name == "Serving Date")
grouping_id = group_item.grouping_id;
}

if (grouping_id == 0)
{
Print("Could not find the grouping id");
return (false);
}
else
Print("The grouping id is " + grouping_id.ToString());




bool result1 = AddSomeoneToGroup(first_name, last_name, email_address, apikey, grouping_id, group_name, list);
bool result2 = AddSomeoneToGroup("Stephanie", "Chang", "stephaniechang9@yahoo.com", apikey, grouping_id, group_name, list);
bool result3 = AddSomeoneToGroup("David","Huie", "dwhuie@gmail.com", apikey, grouping_id, group_name, list);

return (result1 && result2 && result3);
}



private bool AddSomeoneToGroup(String first_name, String last_name, String email_address, String apikey, Int32 grouping_id, String group_name, listsResults list)
{

// Add the subscriber to the list insterest group
Dictionary<string, object> merge_vars = new Dictionary<string, object>();
merge_vars.Add("FNAME", first_name);
merge_vars.Add("LNAME", last_name);

List<interestGroupings> groupings = new List<interestGroupings>();
interestGroupings ig = new interestGroupings();
ig.id = grouping_id;
ig.name = "Serving Date";
ig.groups = new List<string>();
ig.groups.Add(group_name);
groupings.Add(ig);


merge_vars.Add("GROUPINGS", groupings);

listSubscribeParms param = new listSubscribeParms(apikey, list.id, email_address, merge_vars, EnumValues.emailType.html,false,true,false,false);
listSubscribeInput list_subscribe_input = new listSubscribeInput(param);
listSubscribe ls = new listSubscribe(list_subscribe_input);

listSubscribeOutput output2 = ls.Execute();

if(output2.result)
Print(email_address + " added to the group " + group_name);
else if (output2.api_ErrorMessages.Count > 0 && output2.api_ErrorMessages[0].code == "214")
Print(email_address+" is already subscribed to that group");
else
Print("Could not add "+email_address+" to the group "+group_name);

return (output2.result);
}




}
[/syntax]

Some useful links

http://mailchimp.com/
http://apidocs.mailchimp.com/
http://perceptivemcapi.codeplex.com/