用C#.net发送邮件

 

/// <summary>
        
/// 发送邮件
        
/// </summary>

        internal void Send()
        
{
            System.Web.Mail.MailMessage mailmessage 
= new MailMessage();

            mailmessage.From 
= "fmzzs@126.com";
            mailmessage.To 
= "张大伟";
            mailmessage.Subject 
= "我是主题";
            mailmessage.Body 
= "我是内容";
            mailmessage.Cc 
= "张明";


            mailmessage.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate""1");

            mailmessage.Fields.Add
            (
"http://schemas.microsoft.com/cdo/configuration/sendusername",myEmailUserName);
            
//自己邮箱的用户名 
            mailmessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", myEmailPassword);
            
//自己邮箱的密码 
            System.Web.Mail.SmtpMail.SmtpServer ="smtp.126.com"//SMTP Server
            System.Web.Mail.SmtpMail.Send(mailmessage);

        }



这个方法发送邮件有点儿老了,dotnet 2.0 的System.Net空间下有新的发送方式,因为着急,所以没看.这个就当是学习笔记了,下次再研究新的。

posted @ 2008-05-13 17:33  GodSpeed  阅读(1181)  评论(0编辑  收藏  举报