HTML table pass as a string argument to controller action and extract table and get specific value from <td></td> and save in data base and also email this table to another. For example a html table with tag pass as a string this is html string.

<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\"><tr><td>Type</td><td>%@</td></tr><tr><td>Name</td><td>%@</td></tr><tr><td>Email</td><td>%@</td></tr><tr><td>App Version</td><td>%@</td></tr><tr><td>iOS Version</td><td>%@</td></tr><tr><td>Message</td><td>%@</td></tr></table>

And this is method that extract and save this info in database and email to other one.

[HttpPost, ValidateInput(false)]

public ActionResult Calculator(string message)

{

if (Request.UserAgent != "CalculatorFeedback")

{

throw new HttpException(404, "Not found");

}

else

{

string server = System.Configuration.ConfigurationManager.AppSettings["Server"];

int smtpPort = int.Parse(System.Configuration.ConfigurationManager.AppSettings["smtpPort"]);

string emailadd = System.Configuration.ConfigurationManager.AppSettings["loginName"];

string password = System.Configuration.ConfigurationManager.AppSettings["password"];

string senderName = "Calculator Feedback";

string sender = System.Configuration.ConfigurationManager.AppSettings["senderEmail"];

string recipentEmail = System.Configuration.ConfigurationManager.AppSettings["recipentEmail"];

Nisware.Mail.NisEmail email = new Nisware.Mail.NisEmail(server, smtpPort, sender, senderName, true, false, emailadd, password);

email.ErrorMessage = "email not sent";

string pattren = "<td.*?>(.*?)</td>";

MatchCollection matches = System.Text.RegularExpressions.Regex.Matches(message, pattren);

List<string> str = new List<string>();

foreach (Match s in matches)

{

string val = s.Groups[1].Value;

str.Add(val);

}

if (str.Count > 1)

{

WezizFeedback.DataClassesDataContext db = new DataClassesDataContext();

var a = new WezizMail();

a.Mail_Type = str[1];

a.UserName = str[3];

a.Email = str[5];

a.App_version = str[7];

a.IOS_version = str[9];

a.Message = str[11];

a.App_Name = senderName;

db.WezizMails.InsertOnSubmit(a);

string body = string.Format("Viewer Type:{0},\nApp User:{1},\nUser Email:{2},\nApp Version:{3}\nIOS Version:{4},\nMessage:{5}", str[1], str[3], str[5], str[7], str[9], str[11]);

db.SubmitChanges();

email.ErrorMessage = "email not sent";

email.AddRecipient(emailadd, "Weziz Support");

email.SetSubject("Calculator");

email.SetBodyMessage(body);

}

else

{

email.ErrorMessage = "Email not sent";

}

WezizFeedback.Models.GenericResponse resp = new GenericResponse();

try

{

resp.ErrorCode = email.Send();

if (resp.ErrorCode < 0)

{

resp.Message = email.ErrorMessage;

}

else

{

resp.Message = "Email send";

}

}

catch (Exception ex)

{

resp.ErrorCode = -3;

resp.Message = ex.Message;

}

return Json(resp, JsonRequestBehavior.AllowGet);

}

}