asp.net core web api中的Html怎么写,只能用assignment,call,increment,decrement,await,new object expressions作为语句
How to write Html in asp.net core web api , Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
我想在 ASP.NET Core 6.0 Web API 中通过电子邮件发送消息。
public void SendMail(string password, string to)
{
var host = _config.GetSection("Email:HOST").Value;
var port = _config.GetSection("Email:PORT").Value;
var fromEmail = _config.GetSection("Email:Credentials:Username").Value;
var passwordOfFromEmail = _config.GetSection("Email:Credentials:Password").Value;
var toEmail = to;
using (MailMessage mm = new MailMessage(fromEmail, toEmail))
{
mm.Subject = "Your Secret Password";
// mm.Body = "Your Secret Password is " + password;
mm.IsBodyHtml = true;
mm.Body = $"<p>Your Secret Password is " + password + "</b> To unsubscribe your account, <form method=\"post\" action=\"http://localhost:5000/api/newsletter-subscription/public/unsubscribe\" class=\"inline\"> <input name=\"email\" value="toEmail"> <button type = \"submit\" name = \"submit_param\" value ="toEmail" class=\"link-button\"> Click Here </button> </form>.</p>";
// removed rest
}
}
我收到这个错误:
Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement [Application]
; expected [Application] at value="toEmail"
您只能使用“{toEmail}”来插入电子邮件值
mm.Body = $"<p>Your Secret Password is { password }</b> To unsubscribe your account,
<form method=\"post\" action=\"http://localhost:5000/api/newsletter-subscription/public/unsubscribe\" class=\"inline\">
<input name=\"email\" value=\"{toEmail}\"> <button type = \"submit\" name = \"submit_param\"
value = \"{toEmail}\" class=\"link-button\"> Click Here </button> </form>.</p>";
我想在 ASP.NET Core 6.0 Web API 中通过电子邮件发送消息。
public void SendMail(string password, string to)
{
var host = _config.GetSection("Email:HOST").Value;
var port = _config.GetSection("Email:PORT").Value;
var fromEmail = _config.GetSection("Email:Credentials:Username").Value;
var passwordOfFromEmail = _config.GetSection("Email:Credentials:Password").Value;
var toEmail = to;
using (MailMessage mm = new MailMessage(fromEmail, toEmail))
{
mm.Subject = "Your Secret Password";
// mm.Body = "Your Secret Password is " + password;
mm.IsBodyHtml = true;
mm.Body = $"<p>Your Secret Password is " + password + "</b> To unsubscribe your account, <form method=\"post\" action=\"http://localhost:5000/api/newsletter-subscription/public/unsubscribe\" class=\"inline\"> <input name=\"email\" value="toEmail"> <button type = \"submit\" name = \"submit_param\" value ="toEmail" class=\"link-button\"> Click Here </button> </form>.</p>";
// removed rest
}
}
我收到这个错误:
Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement [Application]
; expected [Application] at
value="toEmail"
您只能使用“{toEmail}”来插入电子邮件值
mm.Body = $"<p>Your Secret Password is { password }</b> To unsubscribe your account,
<form method=\"post\" action=\"http://localhost:5000/api/newsletter-subscription/public/unsubscribe\" class=\"inline\">
<input name=\"email\" value=\"{toEmail}\"> <button type = \"submit\" name = \"submit_param\"
value = \"{toEmail}\" class=\"link-button\"> Click Here </button> </form>.</p>";