Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to send a HTML email from Asp.net MVC?

I would like to be able to render a view and send it as an email, similar to what can be done with Ruby on Rails. What is the best way to do this?

EDIT: My solution so far is to use a templating engine (NHaml, StringTemplate.net). It works but I would prefer not to have a second template engine in my site.

like image 515
liammclennan Avatar asked Sep 23 '08 01:09

liammclennan


2 Answers

Once the post mvc-preview-5-rendering-a-view-to-string-for-testing has an answer with a solution in it, that solution applies to this one as well. Once you have a string, you coud mail it using default .net mail options (as indicated by dimarzionist: SendMail / SmtpClient).

like image 127
Casper Avatar answered Oct 06 '22 23:10

Casper


You can consider MvcMailer. See the NuGet package here and the project documentation

Hope it helps!

like image 43
Sohan Avatar answered Oct 06 '22 23:10

Sohan