Mailkit电子邮件未显示为可点击链接

时间:2018-05-08 17:40:03

标签: c# asp.net-mvc asp.net-core mailkit

我正在尝试发送确认电子邮件,一切正常,但链接以纯文本形式发布,而不是可点击链接。

这是我的代码:

        public static Task SendEmailConfirmationAsync(this IEmailSender emailSender, string email, string link)
    {
        return emailSender.SendEmailAsync(email, "Please Confirm your email",
            $"Please confirm your account by clicking this link: <a href='{link}'>link</a>");
    }

Screenshot of email link

提前谢谢

3 个答案:

答案 0 :(得分:1)

请务必检查您使用的电子邮件客户端是否以HTML格式显示电子邮件。从屏幕截图中可以看出,电子邮件是以纯文本显示的。

答案 1 :(得分:0)

使用NETCore.MailKit.Core;

为html类型添加true: EmailService.Send(user.Email,“重设密码”,$“请单击此处重设密码:链接”,true)

答案 2 :(得分:0)

您必须向我们发送邮件模板。你是如何在 html 页面上编写这段代码的。 像字符串一样获取链接并创建一个邮件模板,并在标签中写入 <!-- data-hidden would be set by default --> <!-- data-value would be obtained from the server via ajax or templating engine --> <span id="resetCode" data-hidden="true" data-value="724814">******</span> <button id="showCode">Show Code</button> <button id="hideCode" class="hidden">Hide Code</button> 并且在 html 中您必须编写 MailText = MailText.Replace("[FirstName]", user.FirstName).Replace("[email]", user.Email).Replace("[URL]", URL)