jmail发送邮件的问题,做过邮件发送的高手请进!!分不够再加!
第一次用jmail邮件发送的程序,可是有几个问题想请教:
1.为什么要求发送方的邮件地址和服务器邮箱地址要求匹配?(就是说jmessage.From= "aa@163.com "的时候SmtpServer必须设置成stmp.163.com才能发送成功?是机器设置原因还是jmail本身的限制)
说具体点,我是想实现这样的效果,不知道有没有办法:
http://abc365xyz.com/benzhan/tuijian.htm
2.有没有办法让收件人的地址隐含(匿名),好像有个jmessage.HideRecipients参数是字符型的,不知道怎么设置?
下面是我写的程序:
jmail.Message jmessage = new jmail.MessageClass();
jmessage.Charset= "gb2312 ";
jmessage.From= "hengzhenews@hengzhe.com ";
jmessage.FromName= "应聘信息 ";
jmessage.ReplyTo=Sender;
jmessage.ContentType= "text/html ";
jmessage.Subject= Title;
jmessage.AddRecipient(Receiver, "aa ", "123 ");
jmessage.Body= Content;
jmessage.MailServerUserName= UserName;
jmessage.MailServerPassWord=Password;
try
{
jmessage.Send(SmtpServer,false) ;
jmessage.Close();
return "邮件发送成功! ";
}
catch(Exception er)
{
string fd = er.Message;
return "邮件发送失败! ";
}
------解决方案--------------------1.为什么要求发送方的邮件地址和服务器邮箱地址要求匹配?(就是说jmessage.From= "aa@163.com "的时候SmtpServer必须设置成stmp.163.com才能发送成功?
---------
因为要去你邮箱所在的服务器验证啊,你不设置万stmp.163.com.系统怎么知道去那里验证你的aa@163.com是不是存在呢
------解决方案--------------------我一直用.net framework类库实现邮件发送,似乎也很稳定啊。
http://blog.csdn.net/luck0235/archive/2006/11/11/1379431.aspx
------解决方案--------------------我给你
经过测试没问题可以多发!
1.安装jmail4.3
2.找到jmail.dll(Program Files\Dimac\w3JMail4下)
3.执行Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin\ildasm.exe(可使用Visual Studio .Net 2003 命令提示),
格式如下:tlbimp c:\Program Files\Dimac\w3JMail4\jmail.dll /out:myJmail.dll /namespace:myJmail
就是我在Visual Studio .Net 2005命令提示下编译执行 tlbimp c:\Program Files\Dimac\w3JMail4\jmail.dll /out:myJmail.dll /namespace:myJmail
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Web.Util;
using myJmail;
using Tool;
using Manager;
using Entity;
public partial class UserControls_Jmaill : System.Web.UI.UserControl
{
string strCurrentPath = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSend_Click(object sender, EventArgs e)
{
try
{
this.lblTitle.Text = "发送邮件控件 ";
myJmail.Message Jmail = new myJmail.Message();
DateTime t = DateTime.Now;
String Subject = this.txtTitle.Text;
String body = this.txtContent.Text;
string FromEmail = this.txtFormEmail.Text.Trim();//你的email
String ToEmail = this.txtToEmail.Text;//对方的email
String AddAttachment = this.FileUploadSubject.PostedFile.FileName;
//Silent属性:如果设置为true,JMail不会抛出例外错误. JMail. Send( () 会根据操作结果返回true或false
Jmail.Silent = true;
//Jmail创建的日志,前提loging属性设置为true
Jmail.Logging = true;
//字符集,缺省为 "US-ASCII "