1

I'm using the ActionMailer.Net.Standalone package in a class library. In the root of the project I have a folder called "Templates" where I have my file OrderConfirmation.html.cshtml.

Like this:

enter image description here

Here is my mailer class:

public class Mailer : RazorMailerBase, IMailer
    {
        public RazorEmailResult OrderConfirmation(string toAddress, Order order)
        {
            To.Add(toAddress);
            From = "foo@bar.com";
            Subject = "Account Verification";
            return Email("OrderConfirmation", order);
        }

        public override string ViewPath
        {
            get { return "Templates"; }
        }
    }

When I run the project, I get the following error

"Could not find any CSHTML or VBHTML views named [OrderConfirmation] in the path [Templates]. Ensure that you specify the format in the file name (ie: OrderConfirmation.txt.cshtml or OrderConfirmation.html.cshtml)"

I'm guessing the path isn't correct. What path should I be using?

Thanks.

Mike
  • 2,561
  • 7
  • 34
  • 56
  • Try `Email("Temmplates/OrderConfirmation", order);` or `Email("/Temmplates/OrderConfirmation", order);` –  May 10 '13 at 16:43
  • and try the above suggestion with `public class MailController : MailerBase` –  May 10 '13 at 16:48
  • Did you solve this??? I had the same problem :(... My project is a little complicate since I'm doing it as web service – Jaider May 17 '13 at 15:17
  • No I didn't. I'm using it directly in my MVC project for the time being. I was going to contact the author. – Mike May 21 '13 at 13:41

2 Answers2

1

ActionMailer expects absolute path to ViewPath folder, i.e. in your case it should be like "c:\Mike\GreatProjects\eshop\Templates", not just relative "Templates".

romb
  • 26
  • 3
0

I went to my view properties: "Verification.txt.cshtml", and I changed Build Action: Content, and the Copy to Output Directory: Copy Always, like this:

enter image description here

Jaider
  • 14,268
  • 5
  • 75
  • 82