首页 > 开发 > 综合 > 正文

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

2024-07-21 02:18:27
字体:
来源:转载
供稿:网友
首先,下载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="[email protected]";
jmessage.fromname= "eric lv" ;
jmessage.replyto="[email protected]";
jmessage.subject="test email from jmessage";
jmessage.addrecipient("[email protected]" ,"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() ;
}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表