日期:2013-04-23  浏览次数:20456 次

首先,下载jmail组件,可以直接安装;也可以找到jmail.dll,手动注册组件。命令行环境下,到jmail.dll所在目录,运行regsvr32 jmail.dll,C#程序中,行首加上using jmail,如下:(点击btnSend按钮后发送邮件)
using jmail;

private void btnSend_Click(object sender, System.EventArgs e)
{
jmail.Message jmessage=new jmail.MessageClass();
jmessage.Charset="GB2312";
jmessage.From="fromuser@benq.com";
jmessage.FromName= "eric lv" ;
jmessage.ReplyTo="replayto@benq.com";
jmessage.Subject="test email from jmessage";
jmessage.AddRecipient("receiver@benq.com" ,"eric lv","123");
jmessage.Body= "jmail 内容" ;
jmessage.MailServerUserName= "eric lv" ;
jmessage.MailServerPassWord= "user password" ;
jmessage.Send("smtp-server",false) ;
MessageBox.Show("email sent successfully!");
jmessage.Close() ;
}