【发布时间】:2020-09-22 04:26:39
【问题描述】:
我能够发送普通电子邮件(带有纯文本正文)。我现在想使用 html 模板发送电子邮件。我的模板看起来有点像这样。
<div
style="
@import url('https://fonts.googleapis.com/css2?family=Varela+Round&display=swap');
font-family: 'Varela Round', sans-serif;
max-width: 600px;
margin: 0 auto;
"
>
<div
style="
width: 100%;
height: 200px;
border: solid 1px #cd5383;
border-radius: 5px;
padding: 5px;
text-align: justify;
font-size: 20px;
line-height: 30px;
"
>
Hello {Ashish}, <br />
We have received your request to change password in our Portal<br />
<div style="text-align: center; margin-top: 10px;">
<a target="_blank" href="https://www.google.com">
<button
style="
font-family: 'Varela Round', sans-serif;
width: 150px;
height: 37px;
margin-left: 10px;
background-color: #cd5383;
border: none;
color: #fff;
box-shadow: 1px 1px 5px 1px gray;
"
>
Reset Password
</button>
</a>
</div>
<p style="font-size: 15px; text-align: center; color: gray;">
Facing any issue, contact {support@portal.com}
</p>
</div>
</div>
我创建电子邮件的代码如下所示:
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Portal",_configuration.GetSection("Email").GetSection("EmailAddress").Value));
message.To.Add(new MailboxAddress(userDetails.CompanyEmail));
message.Subject = "Password Reset Link";
message.Body = new TextPart("html")
{
};
我现在如何使用此模板发送电子邮件?
【问题讨论】:
标签: html asp.net-core mailkit mime-message