1

クラス ライブラリで ActionMailer.Net.Standalone パッケージを使用しています。プロジェクトのルートには、"Templates" というフォルダーがあり、そこにファイル OrderConfirmation.html.cshtml があります。

このような:

ここに画像の説明を入力

これが私のメーラークラスです:

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"; }
        }
    }

プロジェクトを実行すると、次のエラーが表示されます

"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)"

パスが間違っていると思います。どのパスを使用すればよいですか?

ありがとう。

4

2 に答える 2

1

ActionMailer は、ViewPath フォルダーへの絶対パスを想定しています。つまり、あなたの場合は、相対 "Templates" ではなく、"c:\Mike\GreatProjects\eshop\Templates" のようにする必要があります。

于 2013-06-06T13:40:38.243 に答える