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