我有用于向新帐户注册发送确认电子邮件的代码。我想要页面上的按钮,以便客户在以前未收到他们的电子邮件时,可以使用该按钮将电子邮件确认链接重新发送到他们的电子邮件
还没有尝试过,我是.NET MVC的新手,它基于NopCommerce。
public class EmailService : IIdentityMessageService
{
public Task SendAsync(IdentityMessage message)
{
// Plug in your email service here to send an email.
string text = message.Body;
string html = message.Body;
//do whatever you want to the message
MailMessage msg = new MailMessage();
msg.From = new MailAddress("support@easypostagelabels.com");
msg.To.Add(new MailAddress(message.Destination));
msg.Subject = message.Subject;
msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(text, null, MediaTypeNames.Text.Plain));
msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html));
SmtpClient smtpClient = new SmtpClient("easypostagelabels.com", 25);// Convert.ToInt32(25));//587
smtpClient.EnableSsl = false;
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("support@easypostagelabels.com", "Admin@1234");
smtpClient.Credentials = credentials;
try
{
smtpClient.Send(msg);
string texterr = "success";
// WriteAllText creates a file, writes the specified string to the file,
// and then closes the file. You do NOT need to call Flush() or Close().
System.IO.File.WriteAllText(HttpContext.Current.Server.MapPath("/Content/error.txt"), texterr);
}
catch (System.Net.Mail.SmtpException E)
{
string texterr = E.Message;
// WriteAllText creates a file, writes the specified string to the file,
// and then closes the file. You do NOT need to call Flush() or Close().
System.IO.File.WriteAllText(HttpContext.Current.Server.MapPath("/Content/error.txt"), texterr);
}
return Task.FromResult(0);
}
}
指导我有关客户用于重新发送电子邮件确认链接的代码