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

类别:.NET开发 点击:0 评论:0 推荐:
首先,下载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() ;
  }

本文地址:http://com.8s8s.com/it/it42223.htm