注册jmail windows --> 运行 --> cmd --> cd jmail目录 --> regsvr32 jmail.dll --> 注册成功
public static void JMail(string ToEmail, string UserName, string ValuationType, string Body, string EmailAccount, string EmailPwd, string EmailServer) { Message Jmail = new Message(); DateTime t = DateTime.Now; var Subject = UserName ;//邮件标题 //添加收件人 var mail = ToEmail.Split(';').ToArray(); for (int i = 0; i < mail.Length; i++) { Jmail.AddRecipient(mail[i], "", ""); } //Silent属性:如果设置为true,JMail不会抛出例外错误. Jmail.Silent = true; //Jmail创建的日志,前提loging属性设置为true Jmail.Logging = true; //字符集,缺省为"US-ASCII" Jmail.Charset = "GB2312"; //信件的contentype. 缺省是"text/plain" 字符串如果你以HTML格式发送邮件, 改为"text/html"即可。 Jmail.ContentType = "text/html"; //发件人邮件用户名 Jmail.From = EmailAccount; Jmail.FromName = UserName; Jmail.ReplyTo = EmailAccount; //发件人邮件用户名 Jmail.MailServerUserName = EmailAccount; //发件人邮件密码 Jmail.MailServerPassWord = EmailPwd; //设置邮件标题 Jmail.Subject = Subject; ////邮件添加附件(增加附件可再加一条Jmail.AddAttachment( "c:\test.jpg",true,null);就可以搞定了。 ////增加附件后要把上面的Jmail.ContentType="text/html";删掉,否则会在邮件里出现乱码。 //Jmail.AddAttachment("c:\test.jpg", true, null); //邮件内容 Jmail.Body = Body; //设置SMTP服务器 var s = Jmail.Send(EmailServer, false); //关闭Jmail连接 Jmail.Close(); }