白天有雨

此处应该有掌声

导航

使用jmail组件发送电子邮件(C#)

首先,下载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() ;
}

posted on 2005-12-31 14:29  卓如  阅读(597)  评论(2编辑  收藏  举报