mari muthu

mari muthu

  • NA
  • 198
  • 103.9k

Create separate view for sending email (body) in ASP.NET MVC

Apr 18 2016 8:27 AM
public class SendMailerController : Controller   {       //       // GET: /SendMailer/       public ActionResult Index()       {           return View();       }       [HttpPost]       public ViewResult Index(SendMail.Models.MailModel _objModelMail)      {           if (ModelState.IsValid)           {               MailMessage mail = new MailMessage();               mail.To.Add(_objModelMail.To);               mail.From = new MailAddress(_objModelMail.From);               mail.Subject = _objModelMail.Subject;               string Body = _objModelMail.Body;               mail.Body = Body;               mail.IsBodyHtml = true;               SmtpClient smtp = new SmtpClient();               smtp.Host = "smtp.gmail.com";               smtp.Port = 587;               smtp.UseDefaultCredentials = false;               smtp.Credentials = new System.Net.NetworkCredential               ("username", "password");// Enter seders User name and password               smtp.EnableSsl = true;               smtp.Send(mail);               return View("Index", _objModelMail);           }           else           {               return View();           }       }   }
hi frnds,

I am a Beginner in Asp.net Mvc i have one doubt over here..i am trying to send mail to Particular user..the mail has send Properly.but i need to send some different design and i Create some Table Structures also to the user.so how can i done this if its Possible create Separate View for Email...?

if you know this Please share your Code or share some link whatever it is Please help for this .

Answers (3)