2004.11.5 利用 System.Web.Mail 发送邮件

王朝system·作者佚名  2006-01-09
宽屏版  字体: |||超大  

母亲明天就要回老家了,祝她一路顺风!

在别人的blog上看到的一段代码。引自:http://blog.joycode.com/ghj/archive/2004/02/17/13197.aspx

下面代码在使用前需要引用System.Web.dll

private void Page_Load(object sender, System.EventArgs e)

{

MailMessage mail = new MailMessage();

mail.To = "me@mycompany.com";

mail.From = "you@yourcompany.com";

mail.Subject = "this is a test email.";

mail.Body = "Some text goes here";

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here

SmtpMail.SmtpServer = "mail.mycompany.com"; //your real server goes here

SmtpMail.Send( mail );

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有