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)
{
Join the conversation! Your thoughts help the community grow.