views:

323

answers:

3

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.

A: 

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
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
@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
@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
I have to agree with LiamMclennan, The question should quite clear to anyone familiar with ASP.NET MVC.
Stefan Rusek
+1  A: 

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

Casper
A: 

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

liammclennan
Your link doesn't work here.
Pascal Paradis
Works for me...
liammclennan