Brian David Berman
Brian David Berman

Reputation: 7694

HTML Email created with ASP.NET MVC 2 View (standard view engine)

Is there a way to email an ASP.NET View using the standard view engine (not spark)?

Upvotes: 4

Views: 1321

Answers (5)

Sohan
Sohan

Reputation: 3805

Did you take a look at MvcMailer? See the NuGet package here and the project documentation

Hope it helps!

Upvotes: 1

David Glenn
David Glenn

Reputation: 24532

Andrew Davey done a recent presentation on Generating email with View Engines at mvcConf 2.

You can find out more information about the open source Postal project he created from the Postal project site or download it via NuGet.

It allows you to generate emails from the Razor view engine as well as the WebForms view engine.

Upvotes: 5

Todd Smith
Todd Smith

Reputation: 17272

You can render a view to a string then send that as the body of your message using:

MailMessage message = new MailMessage ();
AlternateView htmlView = AlternateView.CreateAlternateViewFromString (htmlMessage, "text/html")
message.AlternateViews.Add (htmlView);

Upvotes: 1

Shea Daniels
Shea Daniels

Reputation: 3270

You might want to take a look at Postal and see if that works for you.

Upvotes: 4

Darin Dimitrov
Darin Dimitrov

Reputation: 1039398

If by standard view engine you mean WebForms then you could take a look at this blog post. If by standard view engine you mean Razor you may take a look at the following blog post. You may also take a look at MvcContrib way of doing it. And also DotLiquid.

Upvotes: 5

Related Questions