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
582 stars 178 forks source link

Umbraco issue #129

Open pavelmatusyak opened 10 years ago

pavelmatusyak commented 10 years ago

Hey,

I'm using with umbraco but I have following issue:

Server Error in '/' Application.
Value cannot be null.
Parameter name: routeData

Here is my controller

private IUserMailer _userMailer = new UserMailer();
_userMailer.Welcome(registerFormModel).Send();

And my Welcome method

public virtual MvcMailMessage Welcome(RegisterModel model)
{
   return Populate(x =>
            {
                x.Subject = "Welcome";
                x.ViewName = "Welcome";
                x.To.Add(model.Email);
            });
}

My web config:

<smtp deliveryMethod="Network">
   <network host="test.server.com" />
</smtp>
maxpavlov commented 10 years ago

Hi. Yep, I had the same issue when I was trying to use MVCMailer with Umbraco. So if it has a workaround, that would be great to see so I can go back to using MVCMailer.

ProNotion commented 9 years ago

The responses in this issue led me to my solution:

        var data = new RouteData();
        data.DataTokens["playermailer"] = "PlayerMailer";
        this.ControllerContext = new ControllerContext(context, data, this);

context in this case is the HttpContext which is passed into the constructor. PlayerMailer is the directory containing the views.

ProNotion commented 8 months ago

Glad I posted this for my future self as I just hit the problem again on an old site and uncovered this while looking for a solution! 😄

The responses in this issue led me to my solution:

        var data = new RouteData();
        data.DataTokens["playermailer"] = "PlayerMailer";
        this.ControllerContext = new ControllerContext(context, data, this);

context in this case is the HttpContext which is passed into the constructor. PlayerMailer is the directory containing the views.

Glad I posted this for my future self as I just stumbled across it again while looking for the solution in an old site 😄