Sohan's Blog

Living the Developer's Life

My Article at CodeProject: MvcMailer

I just released a .Net NuGet package called MvcMailer and to get people super easily started, put an article at You are most welcome to the article at
I welcome your comments and suggestions!


Just released 0.8 and it should work. But please let me know if it doesn't.
I also added multi-part emails in version 0.8. You may check that out as well.
One important change:
mail.Body = PopulateBody(mail, "welcome") needs to be replaced with PopulateBody(mail, "Welcome"), it gets rid of the duplication
This comment has been removed by the author.
Brilliant! Can't wait. Could you post a comment here or send me a line to jkonecki [at] when the new release is out so I can test it as well?
Thanks for your reply. I will test this out before I push a new release. The new release will also add multi-part emails so that you can easily send html and plain text emails.
My route is defined as:

routes.Add("Account", new Route("{account}/{controller}/{action}/{id}",
new RouteValueDictionary(new { account = "", controller = "Home", action = "Index", id = "" }), new AccountMvcRouteHandler()));

I'm trying to render a link:
href="@Url.Abs(Url.Action("About", "Home"))"

The url that is generated looks like:


instead of

Can you please share your specific route and ActionLink in mailer view that breaks for the route data?

I know a solution to your problem now. But I would like to make sure I know the problem in detail.
Great! I'm waiting impatiently… ;-)

PS. Congratulations on joining ThoughtWorks
Yes, a new version is overdue now:)

Will you release a new version through NuGet? I will be able to upgrade easily and test it for you.

Thanks for your suggestion. I will fix this issue this weekend.

Thirst of all, thank you for a brilliant package! It's simple and easy to use!

I've just found one little issue - I've notices that the ControllerContext for Notifier doesn't have the RouteData dictionary populated with the same values as the RouteData for main controller. This causes UrlHelper to generate invalid Urls. My app is a multi-tenant one and all my routes have format: /{account}/{controller}/{action}/ I've managed to 'fix' it by adding following code in the WelcomeMessage.cshtml

this.Url.RequestContext.RouteData = (this.Context.CurrentHandler as MvcHandler).RequestContext.RouteData;

I wonder if you could fix it properly, then MvcMailer will be just perfect! ;-)

Thank you,