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

MVC Areas and _Layout Issue #32

Closed mattfraley closed 12 years ago

mattfraley commented 12 years ago

I am using MVC areas for my administration. When I send an email from a controller in the admin area, it uses the _Layout.cshtml from the admin area, rather than the _Layout.cshtml in the Views\UserMailer folder. Even if I specify the Layout in the view like below, it still uses the _Layout in the admin area.

@{ Layout = "~/Views/UserMailer/_Layout.cshtml"; }

mattfraley commented 12 years ago

I guess I spoke too soon. In the UserMailer class, I commented out "MasterName="_Layout"; and it worked just fine.

Thanks for a great product!

lruckman commented 11 years ago

How did I miss that?! Thanks just what I was looking for!

ghost commented 10 years ago

This didn't work for me. Any other ideas?

waris041 commented 8 years ago

This didn't work for me either.Now mvcmailer start using the master_layout.

mbasirati commented 8 years ago

didn't work for me too.

mbasirati commented 8 years ago

Rename the _Layout.cshtml in your mailer folder to something else such as _LayoutMailer.cshtml

Rename the MasterName in your mailer constructor to the same as follows:

 public class UserMailer : MailerBase
{
    public UserMailer()
    {
        MasterName = "_LayoutMailer";
    }
    ...
}

Thanks from ozzii