问题描述
[color=#000000]第一次采用网站绑定邮件收发功能!但是遇到了问题部分邮件乱码还有不能接收QQ邮件试过很多插件都不可以163新浪都行!请大虾请指教!我做的步骤:第一步:下载安装JMail44_pro.exe这是破解版的csdn有下载!第二步:下载jmail.dll这是dll文件项目中引用jmail.POP3ClasspopMail=newPOP3Class();//建立邮件信息接口jmail.MessagemailMessage;//建立附件集接口jmail.Attachmentsatts;//建立附件接口jmail.Attachmentatt;List<MailInfo>MailInfos=newList<MailInfo>();try{popMail.Connect("hzpdwyyx@163.com","Hzpdwyyx.2@","pop.163.com",110);//popMail.Connect("237136969@qq.com","Hzpdqq.2@77","pop.qq.com",110);#regionlsv////ViewlsvMail=View.Details;//ListViewlsvMail=newListView();////Allowtheusertoedititemtext.//lsvMail.LabelEdit=false;////Allowtheusertorearrangecolumns.//lsvMail.AllowColumnReorder=true;////Selecttheitemandsubitemswhenselectionismade.//lsvMail.FullRowSelect=true;////Displaygridlines.//lsvMail.GridLines=true;////Sorttheitemsinthelistinascendingorder.#endregion#region如果收到邮件if(0<popMail.Count){//根据取到的邮件数量依次取得每封邮件for(inti=1;i<=popMail.Count;i++){//这里是判断数据库是否存在此邮件存在则跳出,不存在则添加到数据库,以及下载文件到服务器stringmessageUID=popMail.GetMessageUID(i);if(DAL.isEmailData(messageUID)==true){continue;}else{//取得一条邮件信息mailMessage=popMail.Messages[i];//取得该邮件的附件集合atts=mailMessage.Attachments;//设置邮件的编码方式mailMessage.Silent=true;mailMessage.EnableCharsetTranslation=true;mailMessage.ContentTransferEncoding="Base64";mailMessage.Encoding="base64";mailMessage.Charset="gb2312";mailMessage.ContentType="text/html";mailMessage.ISOEncodeHeaders=false;//是否将信头编码成iso-8859-1字符集//mailMessage.Charset="utf-8";//mailMessage.ContentType="text/plan";//mailMessage.ISOEncodeHeaders=true;//是否将信头编码成iso-8859-1字符集//将信息加入model//MailInfoMailInfoObj=newMailInfo();//MailInfoObj.MailSubject=mailMessage.Subject;//MailInfoObj.MailMessage=mailMessage.Body;//MailInfoObj.FromMail=mailMessage.From;//MailInfoObj.FromMailName=mailMessage.FromName;stringAttachmentsPath="";for(intj=0;j<atts.Count;j++){//取得附件att=atts[j];//附件名称attsatturl=newatts();atturl.attss=context.Server.MapPath("/upLoad/")+att.Name;//stringatturl="e:\"+att.Name;//上传到服务器if(!File.Exists(atturl.attss)){att.SaveToFile(atturl.attss);}//MailInfoObj.atts.Add(atturl);if(AttachmentsPath==""){AttachmentsPath="upLoad/"+att.Name;}else{AttachmentsPath+=",upLoad/"+att.Name;}}//MailInfos.Add(MailInfoObj);//将信息保存到数据库DAL.AddEmailData(messageUID,mailMessage.Subject,mailMessage.Body,mailMessage.From,mailMessage.FromName,mailMessage.Date.ToString(),AttachmentsPath);#regionlsv//ListViewItemitem=newListViewItem();//item.Text=mailMessage.From;//item.Tag=MailInfoObj;//lsvMail.Items.Add(item);#endregion}}}else{strings="没有新邮件!";}#endregion//popMail.DeleteMessages();popMail.Disconnect();popMail=null;}catch(Exceptionex){//strings="请检查邮件服务器的设置是否正确!";context.Response.Write(ex.ToString());}我的发件是.net自带qq163皆可以再次提醒163.com接收,发件都行就QQ不能jmail收件提示POP3:-ERR登录失败,请使用安全连接(如ssl)
解决方案
解决方案二:
还有就是乱码问题