Keh*_*mme 13 c# email asp.net-mvc system mailmessage
我正在尝试发送密码重置电子邮件,但我无法确定如何指定发件人的地址.
这是我正在尝试做的事情:
MailMessage mail = new MailMessage();
mail.From.Address = "support@mycompany.com";
mail.To.Add(Email);
mail.Subject = "Forgot Password";
mail.Body = "<a href=\"" + url + "\">Click here to reset your password.</a>";
SmtpClient smtp = new SmtpClient();
smtp.SendAsync(mail, null);
Run Code Online (Sandbox Code Playgroud)
我确信这是可能的,那么我怎样才能在ASP.Net中实现这一目标?
Keh*_*mme 17
事实证明我已经领先于自己了.
Address从mail.From.Address允许我删除设置值,但需要类型MailAddress.
这是解决方案:
MailMessage mail = new MailMessage();
mail.From = new MailAddress("support@mycompany.com");
mail.To.Add(Email);
mail.Subject = "Forgot Password";
mail.Body = "<a href=\"" + url + "\">Click here to reset your password.</a>";
SmtpClient smtp = new SmtpClient();
smtp.SendAsync(mail, null);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18894 次 |
| 最近记录: |