坚持,坚定,坚强

博客园 首页 新随笔 联系 订阅 管理
使用.net 自带的using System.Web.Mail;来发邮件。
private void SendMail()
        
{
            
try
            
{
                MailMessage mail
=new MailMessage();
                mail.From 
= "<liulurong@163.com>"
                mail.To 
= "shaofei8989@163.com";
                mail.Subject 
= "这是一个病毒!";
                mail.Body
="你死定了。HOHOOHHOHOOOOO";
                mail.BodyEncoding 
= System.Text.Encoding.GetEncoding("GB2312");
                mail.BodyFormat 
= MailFormat.Text;
                mail.Priority 
= MailPriority.High;

                mail.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate""1"); //basic authentication 
                mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername""MaxMan"); //set your username here 
                mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword""123456"); //set your password here 
//这个的smtp服务器要写正确。都是以smtp开头的。    
        SmtpMail.SmtpServer = "smtp.163.com"//your real server goes here 

                SmtpMail.Send( mail ); 
            }

            
catch(Exception ex)
            
{
                
throw ex;
            }

        }
posted on 2006-09-19 19:35  老公鸡  阅读(536)  评论(0)    收藏  举报