ASP.NET MVC: How to send an html email using a controller?

后端 未结 5 1431
挽巷
挽巷 2020-12-15 01:32

What would be the simplest way to send a customised html email using asp.net?

I suppose ideally I would like to send html via email rather than returning it to the b

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 02:02

    I think sending email in mvc is just the same as in web form, you just need to set the atribute of the mail message to html enabled then it is food to go. Like this code

    MailMessage mm = new MailMessage(emmailFrom,emailTo);
    mm.Subject = "Your Subject";
    mm.IsBodyHtml = true;
    mm.Body = body.ToString();
    
    SmtpClient smtp = new SmtpClient();
    smtp.Send(mm);
    

提交回复
热议问题