/// <summary>
/// SendMail 邮件发送程序 Editer:Ghost Date:2003-09-09。
/// 使用方法如下:
/// string form = "[email protected]";
/// string to = "[email protected]";
/// string subject = "主题";
/// string body = "见附件";
/// string attfile = "C:\test.zip";
/// Ghost.Component.SendMail sendmail = new Ghost.Component.SendMail(form,to,subject,body,attfile);
/// if(sendmail.Send)
/// {
/// Response.Write("发送成功!");
/// }
/// else
/// {
/// Response.Write("发送失败!");
/// }
///</summary>
public class SendMail
{
public string From;
public string To;
public string Subject;
public string Body;
public string AttFile; protected string from
{
get
{
return From;
}
set
{
From = value;
}
}
protected string to
{
get
{
return To;
}
set
{
To = value;
}
}
protected string subject
{
get
{
return Subject;
}
set
{
Subject = value;
}
}
protected string body
{
get
{
return Body;
}
set
{
Body = value;
}
}
protected string attfile
{
get
{
return AttFile;
}
set
{
AttFile = value;
}
} public bool Send
{
get
{
return this.SendMessage();
}
} protected bool SendMessage()
{
try
{
jmail.MessageClass mail = new jmail.MessageClass();
mail.From = from;
mail.FromName = "MMPIS";
mail.AddRecipient(to,"","");
mail.Subject = subject;
mail.Body = body;
mail.Charset = "gb2312";
mail.AddAttachment(attfile,false,"");
mail.MailServerUserName = "ghost";
mail.MailServerPassWord = "ghost";
if(mail.Send( "mail.jsqyw.com",false))
{
return true;
}
return false;
}
catch
{
return false;
}
} public SendMail(string from,string to,string subject, string body, string attfile)
{
this.From = from;
this.To = to;
this.Subject = subject;
this.Body = body;
this.AttFile = attfile;
}
public SendMail()
{
//
}
}