Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting template/view to show up in message body of e-mail. #23

Open
remesq opened this issue Jul 24, 2011 · 1 comment
Open

Not getting template/view to show up in message body of e-mail. #23

remesq opened this issue Jul 24, 2011 · 1 comment

Comments

@remesq
Copy link

remesq commented Jul 24, 2011

Sorry if this issue is not appropriate here. A while back I started using MvcMailer and had great results in my MVC3 project. The e-mails were getting sent AND the body (using _Layout.cshtml and [NameOfMailer].cshtml) were showing up in the sent e-mail.

In the last two months I started checking out OrchardCMS (v 1.2), and, after deciding to use it, started moving my MVC3 project over. This included trying to create a module that utilized MvcMailer.

Now, I got the module in OrchardCMS to send the e-mail, HOWEVER, no body appears in the message of the e-mail. I have spent countless hours trying to figure out why. I attempted getting help on the OrchardCMS forums, but to no avail. Which is why, as a last ditch effort, I turn to you for any guidance. Again, I understand if you are unable to help.

I have tried a bunch of things. I looked at the MvcMailer source and saw how MailerBase.cs was switching the controller temporarily to get the template/views (_Layout.cshtml and [NameOfMailer].cshtml). I continue to get my success page for sending the mail (and see it in my GMail inbox) but the message body is empty, i.e., it's not finding the layout or view. I received no page errors - leading to my confusion and leading me to try everything under the sun to get it to work.

Out of the multitude of variations I tried to get this to work, I stumbled upon using "PopulateHtmlBody" instead of "PopulateBody". This confirmed my suspicion that the e-mail was not receiving the view. This is the error I received using "PopulateHtmlBody":


The view 'QuoteMail' or its master was not found or no view engine supports the searched locations. The following locations were searched:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The view 'QuoteMail' or its master was not found or no view engine supports the searched locations. The following locations were searched:

Source Error:

Line 35: PopulateHtmlBody(mailMessage, "QuoteMail", "_Layout");
Line 36: //PopulateBody(mailMessage, "QuoteMail", resources);


Again, the code I am using works outside of OrchardCMS in my MVC3 project without a problem.

It has something to do with how OrchardCMS treats its views/routing. I created routes in my Route.cs under the module project; I even created a QuoteMail controller in the module project. Nothing works. I thought you might have some insight.

Thanks for any guidance.

@smsohan
Copy link
Owner

smsohan commented Jul 24, 2011

With the MVCMailer source code you can debug your mailer and see if
it's hitting anything unusual on its way to finding/using the desired
view.
Just to double check, I would try doing a pickup directory location
and make sure it's alright in terms of HTML, headers, etc.


Sent from my iPhone

S M Sohan
Consultant
ThoughtWorks Canada
Suite 1100, 600 6th Ave SW
Calgary, AB T2P 0S5
Cell: +1 403 714 2673

On 2011-07-24, at 3:23 PM, remesq
reply@reply.github.com
wrote:

Sorry if this issue is not appropriate here. A while back I started using MvcMailer and had great results in my MVC3 project. The e-mails were getting sent AND the body (using _Layout.cshtml and [NameOfMailer].cshtml) were showing up in the sent e-mail.

In the last two months I started checking out OrchardCMS (v 1.2), and, after deciding to use it, started moving my MVC3 project over. This included trying to create a module that utilized MvcMailer.

Now, I got the module in OrchardCMS to send the e-mail, HOWEVER, no body appears in the message of the e-mail. I have spent countless hours trying to figure out why. I attempted getting help on the OrchardCMS forums, but to no avail. Which is why, as a last ditch effort, I turn to you for any guidance. Again, I understand if you are unable to help.

I have tried a bunch of things. I looked at the MvcMailer source and saw how MailerBase.cs was switching the controller temporarily to get the template/views (_Layout.cshtml and [NameOfMailer].cshtml). I continue to get my success page for sending the mail (and see it in my GMail inbox) but the message body is empty, i.e., it's not finding the layout or view. I received no page errors - leading to my confusion and leading me to try everything under the sun to get it to work.

Out of the multitude of variations I tried to get this to work, I stumbled upon using "PopulateHtmlBody" instead of "PopulateBody". This confirmed my suspicion that the e-mail was not receiving the view. This is the error I received using "PopulateHtmlBody":


The view 'QuoteMailMatrimonialUncontested.cshtml' or its master was not found or no view engine supports the searched locations. The following locations were searched:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The view 'QuoteMail' or its master was not found or no view engine supports the searched locations. The following locations were searched:

Source Error:

Line 35: PopulateHtmlBody(mailMessage, "QuoteMail", "_Layout");
Line 36: //PopulateBody(mailMessage, "QuoteMail", resources);


Again, the code I am using works outside of OrchardCMS in my MVC3 project without a problem.

It has something to do with how OrchardCMS treats its views/routing. I created routes in my Route.cs under the module project; I even created a QuoteMail controller in the module project. Nothing works. I thought you might have some insight.

Thanks for any guidance.

Reply to this email directly or view it on GitHub:
#23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants