Sohan's Blog

Things I'm Learning

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 CodeProject.com. You are most welcome to the article at http://www.codeproject.com/KB/aspnet/MvcMailerNuGet.aspx
I welcome your comments and suggestions!

Comments

Sohan
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
Sohan
This comment has been removed by the author.
Jakub
Brilliant! Can't wait. Could you post a comment here or send me a line to jkonecki [at] gmail.com when the new release is out so I can test it as well?
Sohan
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.
Jakub
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:

http://mysite/Home/About

instead of

http://mysite/myaccount/Home/About
Sohan
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.
Jakub
Great! I'm waiting impatiently… ;-)

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

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

Cheers!
Jakub
Sohan
Thanks for your suggestion. I will fix this issue this weekend.
Jakub
Hi!

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,
Jakub