mvc 5 SendEmailAsync with image

时间:2014-12-05 15:07:30

标签: c# asp.net-mvc-5

我正在尝试在用户在我的网站上注册时发送确认电子邮件。

C#是 -

string baseDirectory = System.AppDomain.CurrentDomain.BaseDirectory;

string confirmRegistrationEmail = System.IO.File.ReadAllText(baseDirectory + "Content\\ConfirmRegistration.html").Replace("#logo", baseDirectory + "Content\\Images\\logo.png");

await UserManager.SendEmailAsync(_user.Id, "Confirm your account", confirmRegistrationEmail);

从文件系统加载我的ConfirmRegistration.html文件。那个文件是 -

<html>
<body>
    <img src="#logo" alt="Logo" align="middle">
    <br>
    <b>Thank you for registering with Example Website.</b> Your account has been created.<br>
    <p align ="justify">  <a href="#callbackURL">Click here to confirm and complete the registration process.</a></p>
</body>
</html>

但是我无法显示徽标。

我需要做些什么才能让图像出现?

另外,我需要继续使用SendEmailAsync

1 个答案:

答案 0 :(得分:1)

您必须将其包含在绝对网址中。