smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
584 stars 178 forks source link

Let the view set the subject #67

Closed bogdan-litescu closed 11 years ago

bogdan-litescu commented 11 years ago

I needed to specify the subject of the email in the view rather than hardcoding it in the code or store it separately. This can be extended so more data can come from view such as recipients, reply tos, html body, etc.

Here's the usage:

@{ TempData["Subject"] = string.Format("A new post has been added to {0}", Model.Name); }

smsohan commented 11 years ago

@bogdan-litescu I think it can get quite complicated to push a lot of things to the view. Also in a multipart email, subject is usually shared among the alternate views. Having them in one place makes sense.