1
我是C#的ASP.NET新手。任何人都可以指導我如何使用C#使用服務器(包括配置服務器)通過ASP.NET發送電子郵件。通過asp.net與C#編碼發送電子郵件?
我是C#的ASP.NET新手。任何人都可以指導我如何使用C#使用服務器(包括配置服務器)通過ASP.NET發送電子郵件。通過asp.net與C#編碼發送電子郵件?
using System.Net.Mail;
...
MailMessage message = new MailMessage();
message.From = new MailAddress("[email protected]");
message.To.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));
message.CC.Add(new MailAddress("[email protected]"));
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);
在web.config
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="true" />
</smtp>
</mailSettings>
感謝Scott
海thanx您的回覆......可以請您解釋一下什麼是主機的 「smtpserver1」 用戶名=」用戶名「密碼=」祕密「....在哪裏我將得到所有這些......? – Sri 2010-03-29 04:31:53
谷歌它,你可以設置你自己的,使用你的ISP的,使用谷歌/雅虎郵件smtp服務器。 – 2010-03-29 06:46:24
好的thanx密碼和用戶名是......? – Sri 2010-03-29 07:43:05