用.net自带的类发送E_Mail(ASP.NET+C#)

using System.Web.Util;
using System.Web.Mail;
using System.Net;  

private void Button2_Click(object sender, System.EventArgs e)
  
{
   
try
   
{
    MailMessage Message 
= new MailMessage();
    Message.To 
="laihua0316@163.com";  
    Message.From 
= "laihua80316@163.com"
    Message.Subject 
= "今天心情很好!!"
    Message.Body 
="祝大家工作愉快!!";
    
    Message.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate""1"); 
    Message.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendusername""laihua80316"); //
    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword""******"); //
    SmtpMail.SmtpServer = "smtp.163.com"
    SmtpMail.Send(Message);     
    Response.Write(
"<script>alert('ok')</"+"script>");
   }

   
catch 
   
{
    Response.Write(
"<script>alert('fail')</"+"script>");
   }

  
  }

posted on 2005-03-31 16:51  dragonpro  阅读(382)  评论(0编辑  收藏  举报

Free Web Counter