使用C#发送邮件(是否需要特定的IIS配置)?
我刚刚安装了 IIS,我想启用通过 C# 发送电子邮件。我不知道需要在 IIS 中配置什么。
我尝试了一些事情但没有成功。我是 ASP.net 的初学者。
我使用的代码如下。
// create mail message object
MailMessage mail = new MailMessage();
mail.From = @"[email protected]";// put the from address here
mail.To = @"[email protected]"; // put to address here
mail.Subject = "test"; // put subject here
mail.Body = "test";// put body of email here
SmtpMail.SmtpServer = "localhost"; // put smtp server you will use here
// and then send the mail
I have just installed IIS, and I want to enable sending emails through C#.I don't know what I need to configure in IIS.
I tried few things but invain. I'm very beginner in ASP.net.
The code I use is the following one.
// create mail message object
MailMessage mail = new MailMessage();
mail.From = @"[email protected]";// put the from address here
mail.To = @"[email protected]"; // put to address here
mail.Subject = "test"; // put subject here
mail.Body = "test";// put body of email here
SmtpMail.SmtpServer = "localhost"; // put smtp server you will use here
// and then send the mail
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 IIS7 下,您需要转到 IIS 管理器内的邮件设置。
查看 http://technet.microsoft.com/ en-us/library/cc772058(WS.10).aspx
简而言之
如果您需要安装邮件服务器,请查看 http://learn.iis.net/page.aspx/751/configure-smtp-e-mail-in-iis-7/ 了解详细信息。
Under IIS7 you need to go to your mail settings inside the IIS Manager.
Take a look at http://technet.microsoft.com/en-us/library/cc772058(WS.10).aspx
In short
If you need to install a mail server, take a gander at http://learn.iis.net/page.aspx/751/configure-smtp-e-mail-in-iis-7/ for details.