我创建了注册页面,该页面将自动发送电子邮件用户以确认其帐户。有没有办法将conformations电子邮件发送到不同的域,如hotmail,yahoo,live等等。所有不同的域名(包括.com,.uk,.org等等)。如果是这样,我可以获得如何在c#中使用代码/修改我的代码的代码/文章。这是我发送电子邮件的代码。
using (MailMessage mm = new MailMessage("sender@mydomain.com", txtEmail.Text))
{
mm.Subject = "Account Activation";
string body = "Hello " + txtUsername.Text.Trim() + ",";
body += "<br /><br />Please click the following link to activate your account";
body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("CS.aspx", "CS_Activation.aspx?ActivationCode=" + activationCode) + "'>Click here to activate your account.</a>";
body += "<br /><br />Thanks";
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
NetworkCredential NetworkCred = new NetworkCredential("sender@gmail.com", "password");
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = NetworkCred;
smtp.Send(mm);
}
答案 0 :(得分:1)
您无需执行任何不同的操作即可发送到不同的电子邮件域。