Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C发送邮件(是否需要特定的IIS配置)?_C#_Asp.net_Email_Iis_Sendmail - Fatal编程技术网

C# 使用C发送邮件(是否需要特定的IIS配置)?

C# 使用C发送邮件(是否需要特定的IIS配置)?,c#,asp.net,email,iis,sendmail,C#,Asp.net,Email,Iis,Sendmail,我刚刚安装了IIS,我想启用通过C发送电子邮件。我不知道我需要在IIS中配置什么。 我尝试了几件事,但都失败了。我是ASP.net的初学者 我使用的代码如下 // create mail message object MailMessage mail = new MailMessage(); mail.From = @"asaf.tobi@gmail.com";// put the from address here mail.To = @"asaf.tobi@gmail.com"; // pu

我刚刚安装了IIS,我想启用通过C发送电子邮件。我不知道我需要在IIS中配置什么。 我尝试了几件事,但都失败了。我是ASP.net的初学者

我使用的代码如下

// create mail message object
MailMessage mail = new MailMessage();
mail.From = @"asaf.tobi@gmail.com";// put the from address here
mail.To = @"asaf.tobi@gmail.com"; // 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

在IIS7下,您需要转到IIS管理器中的邮件设置

看看

总之

转到IIS管理器 转到顶级站点以配置所有服务器,或转到特定站点 打开视野 打开SMTP电子邮件 设置适当的邮件详细信息
如果您需要安装邮件服务器,请访问了解详细信息。

在许多情况下,您很可能希望使用在其他地方运行的SMTP服务器。查看您的电子邮件程序是如何设置为使用您的ISP或公司电子邮件服务器的。但是,我们不是都只是使用浏览器收发电子邮件吗;