开发者

No body in message (MvcMailer + Orchard CMS)

I am using MvcMailer with Orchard CMS in a module I created, and although I can get it to send e-mails, the body of the e-mail is empty, leaving me to believe that Orchard is not picking up "/[Module]/Views/[NameOfMailerFolder/_Layout.cshtml" or ".../[NameofMailerView].cshtml".

At first I thought that moving "/[Module]/Views/[NameOfMailerFolder]" either to the "/[ThemeBein开发者_如何学编程gUsed]/Views" folder or to the "/Views" folder of Orchard.Web might work (I thought it was just not finding the paths). But no luck.

I tried playing around with route.cs in my module, but I don't know whether or not I can just leave CONTROLLER and ACTION empty ("") and put the "/[Module]/Views/[NameOfMailerFolder]" in there only. In any event, I created a route for "[NameOfMailerView].cshtml" but that hasn't worked either. I am wondering if this is even the right way to go (I did not set up actions in a controller, but am thinking to do so - just going to have to redirect?).

I'm a bit lost, so I appreciate any guidance.


It turns out that the Mailer code uses a MasterName, which is what appears to cause problems with Orchard CMS's way of doing things.

This is what gets it working for me (using 1.3 or Orchard.Web):

public QuoteMailers()
    : base()
{
    //LEAVE OUT FOLLOWING FOR MVC MAILER TO WORK
    //MasterName = "_Layout";
}

QuoteMailers is just my name, MvcMailer will create a name based on the parameters you use if you are using the Package Manger Console in VS.

Commenting out MasterName is what works! The only drawback to this "hack" is that I don't use a common _Layout file. To me that's no big deal because I am AM able to use Partials.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜