我正在尝试使用SMTP中的SMTP概念发送重置密码实现的电子邮件。我创建了一个电子邮件模板txt文件,如下所示
<html>
<head>
<style type="text/CSS">
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: normal;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.btn:focus,
.btn:active:focus,
.btn.active:focus,
.btn.focus,
.btn:active.focus,
.btn.active.focus {
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
.btn:hover,
.btn:focus,
.btn.focus {
color: #333;
text-decoration: none;
}
.btn:active,
.btn.active {
background-image: none;
outline: 0;
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
}
.btn-default {
background-color:#EE1A30;
color:white;
}
.btn-default:hover {
color: black;
background-color: white;
border-color: #C7C7C7;
}
</style>
</head>
<body>
<div style="width:100%;margin:0 auto;">
<div style="width:75%;">
<div style="width:100%;font-family:Arial,Helvetica,sans-serif;">
<div style="background-color:black;">
<img src="\images\Logo.jpg">
</div>
<div style="background-color:#CECECE;padding:2% 19%;">
<div style="background-color:white">
<div style="background-color:#EE1A30;padding:2% 7%;text-align:center;">
<label style="font-weight:bold;color:white;font-size:15px">FORGOT PASSWORD</label>
</div>
<div style="padding:4%;font-size:14px;align:center">
<label style="">Hi, {0}</label><br><br>
<span>You recently requested to reset your password for your account. Click the button below to reset it.</span><br><br>
<div>
<a href=\"{1}\" title=\"Reset Password\" class="btn btn-default" role="button" style="text-decoration:none;">Reset your password</a>
</div><br>
<span>If you did not request a password reset, please ignore this email. This password reset is valid only for next 30 minutes.</span><br><br><br><br>
<span>Thanks,</span><br>
<span>Team</span>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</body>
在控制器中,我试图通过读取sampleText.txt中的文本来发送电子邮件。
string Body = string.Empty;
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("sample@domain.com");
mailMessage.To.Add(new MailAddress(emailID));
mailMessage.Subject = "Reset password";
using (StreamReader sr = new StreamReader(Server.MapPath("~/folder1/folder2/") + "sampleText.txt"))
{
Body = sr.ReadToEnd();
}
mailMessage.Body = string.Format(Body, userName, Url.Action("action", "controller", new { Token = token, Email = emailID }));
mailMessage.IsBodyHtml = true;
它会抛出异常&#34;输入字符串的格式不正确。&#34;在下面一行,其中传递用户名作为第一个参数,URL作为第二个参数重定向。
mailMessage.Body = string.Format(Body, userName, Url.Action("action", "controller", new { Token = token, Email = emailID }));
帮我解决这个问题。
答案 0 :(得分:2)
要在left join
中转义select c.customer_id,p.product_id
from (select product_id,part_number from product_list) p
cross join (select distinct customer_id from orders) c
left join orders o on p.product_id=o.product_id and p.part_number=o.part_number and c.customer_id=o.customer_id
group by c.customer_id,p.product_id
having count(o.part_number) < count(p.part_number)
和{
,您需要将它们加倍:
如果希望结果包含}
字面值,请使用String.Format
。如果希望结果包含{{
字面值,请使用{
。
这就是它的全部内容。