开发者

Sending mail using C# (Does it needs specific IIS configuration)?

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 = @"asaf.tobi@gmail.com";// put the f开发者_如何学编程rom 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


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

  • Go to IIS Manager
  • Go to the top level site to configure for all of the server or go to your specific site
  • Open the Feartures View
  • Open SMTP Email
  • Set the appropriate mail details

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜