8

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.

liammclennan
  • 5,295
  • 3
  • 34
  • 30

5 Answers5

1

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).

Community
  • 1
  • 1
Casper
  • 1,242
  • 1
  • 11
  • 12
1

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

Hope it helps!

Sohan
  • 3,757
  • 2
  • 24
  • 24
0

This looks like a possible implementation of the approach suggested by Haacked.

liammclennan
  • 5,295
  • 3
  • 34
  • 30
0

I'd advise Postal

It allows you to create e-mails using (strongly typed) MVC views, and send them using the standard SmtpClient.

Tom Lint
  • 483
  • 5
  • 13
-4

Sorry mate, but I thing there is something wrong with your understanding of ASP.NET MVC. It's still the part of ASP.NET and framework, so you can use the same techniques you used there like SendMail and SmtpClient.

dimarzionist
  • 18,517
  • 4
  • 22
  • 23
  • 1
    I thing there is something wrong with your understanding of the question. :) I want to render a view to an email, instead of a HTTP response. I know how to send an email. – liammclennan Sep 23 '08 at 05:07
  • @liammclennan you've dinged @dimarzionist for not understanding your question. How about you make it clearer to all of us what you need is by editing you question text. You want to the output of the view to be the body of your email? I don't understand the question either... – MotoWilliams Sep 23 '08 at 06:12
  • @MotoWilliams: I think my question is as clear as it can be. If you don't understand then perhaps it is just not a question for you. – liammclennan Oct 14 '08 at 00:23
  • I have to agree with LiamMclennan, The question should quite clear to anyone familiar with ASP.NET MVC. – Stefan Rusek Dec 08 '08 at 00:58