当有人在我的网站上注册时,他/她还需要填写他/她的电子邮件地址。
点击“注册”按钮后,系统需要向文本框中写入的电子邮件地址发送一封自动电子邮件。
谁能帮我解决这个问题?
提前致谢!
最佳答案
要在 ASP.NET 中发送电子邮件,您需要查看 System.Net.Mail。有两个步骤可以从 ASP.NET 中发送邮件
1) 电子邮件帐户设置 - 可以在您的 web.config 文件中进行全局设置
<system.net>
<mailSettings>
<smtp from="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="552130262115333a3a7b363a38" rel="noreferrer noopener nofollow">[email protected]</a>">
<network host="host" port="25" userName="username" password="password" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>
2) 设置您的消息 - 在您的注册页面代码后面
MailMessage message = new MailMessage();
message.From = new MailAddress("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="97e4f2f9f3f2e5d7e4f2f9f3f2e5b9f4f8fa" rel="noreferrer noopener nofollow">[email protected]</a>");
message.To.Add(new MailAddress("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fb9e969a9297bb9e969a9297d5989496" rel="noreferrer noopener nofollow">[email protected]</a>"));
message.Subject = "subject";
message.Body = "content";
SmtpClient client = new SmtpClient();
client.Send(message);
http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx
关于c# - 向新用户 aspx 发送自动电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16525806/