I'm a beginner in ASP.net MVC and I have a problem when I want to send my view by email with my controller. I do not arrive to send it, I just arrive send some text
About what I have already tried, I'm gonna show you with the code.
(If my problem is not understandable tel me and I explain differently)
// Page MailHelper.cs
// The tools for sending mail
public static void SendMail(string body)
{
try
{
var mailto = ConfigurationManager.AppSettings["mailto"].Split(';');
MailMessage mail = new MailMessage();
mail.IsBodyHtml = true;
SmtpClient SmtpServer = new SmtpClient();
mail.From = new MailAddress("SendVersionsRobot@trysomething.fr");
foreach (var m in mailto)
mail.To.Add(m);
mail.Subject = "try send Mail";
mail.Body = body;
SmtpServer.Send(mail);
}
catch (Exception ex)
{
}
}
// Page MailController.cs
using....
namespace MvcMovie.Controllers
{
public class MailController : Controller
{
public ActionResult pageDeTest()
{
MailHelper.SendMail(pageDeTest());
return View();
}
}
}
<div id="demo"></div>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
$.getJSON("..\\..\\jsconfig.json", function (data) {
$('#demo').html(JSON.stringify(data));
});
/*console.log("try");*/
</script>