0

mvc でアカウント確認メールの送信に取り組んでいます。以下のようなメール本文のフォーマットを作成し、「EmailFormat.html」というソリューション内のhtmlファイルに保存しました。

<body>
Dear [Name],
<p>Thanks for registration.To activate your account please follow the link below:</p>
<p><a href="[url]"> click here for verification </a></p>
<p>if you are not Name or didn't register on abc.com you can ignore this email.</p>
<p>Regards,</p>
<p>www.abc.com</p>
</body>

メール送信を処理する ac# クラスがあります。上記の html ファイルをメール本文として取得し、[Name] と [url] を実際のランタイム パラメータに置き換えようとします。

 string name = myclass.FirstName + " " + myclass.LastName;
    using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("abc." + "EmailFormat.html"))
    using (StreamReader reader = new StreamReader(stream))
       {
            body = reader.ReadToEnd();
        }             

     body.Replace("[Name]", name);
     string url = HttpUtility.HtmlEncode("http://localhost/Controller/Method/uniqueid")
     body.Replace("[url]",url);
     emailutility.send();//ignore this send code.

メールは問題なく受信できますが、問題は [ここをクリックして確認] をクリックすると、実際の URL ではなく %5Burl%5D に移動することです。

助けてください。

ありがとう

4

1 に答える 1