ASP.NET 网站开发邮件发送用的比较多的是用JAMIL组件,下面我来说说具体的用法.
首先,我们要从网上下载Jamil.dll的组件,然后添加引用using jmail,然后再本机或者服务器上注册一下 将jmail.dll拷贝到服务器的system32目录下,开始-运行-cmd-输入regsvr32 jmail.dll. protected void sendMail(String sender, String senderMail, String receiver, String subject, String content) { jmail.MessageClass jmMessage = new jmail.MessageClass(); //设置字符集 jmMessage.Charset = "gb2312"; //信件的contentype. 缺省是"text/plain") : 字符串如果你以HTML格式发送邮件, 改为"text/HTML"即可。 Jmail.ContentType = "text/HTML"; //发件人邮箱地址 jmMessage.From = senderMail; //发件人姓名 jmMessage.FromName = sender; //设置主题 jmMessage.Subject = subject; //设置内容 jmMessage.Body = content; // 设置收件人邮箱 jmMessage.AddRecipient(receiver, "", ""); // string[] arraymail = MailTo.Split(';'); // for (int i = 0; i < arraymail.Length; i++) // { //Jmail.AddRecipientBCC(arraymail[i], ""); // } // 设置登陆邮箱的用户名和密码 jmMessage.MailServerUserName = "fener2011@163.com"; jmMessage.MailServerPassWord = "******"; //设置smtp服务器地址 if (jmMessage.Send("smtp.163.com", false)) { Response.Write("<script>alert('发送成功')</script>"); } else Response.Write("<script>alert('发送失败')</script>"); } 好的OK了! (责任编辑:admin) |