深入Lumisoft.NET组件开发碰到乱码等问题的解决方(2)


public DateTime Date
        {
            get{
                if(this.IsDisposed){
                    throw new ObjectDisposedException(this.GetType().Name);
                }

MIME_h h = this.Header.GetFirst("Date");
                if(h != null){
                    try{
                        return MIME_Utils.ParseRfc2822DateTime(((MIME_h_Unstructured)h).Value);
                    }
                    catch{

//尝试转换正常的日期
                        DateTime dt;
                        string dateString = ((MIME_h_Unstructured)h).Value;
                        bool success = DateTime.TryParse(dateString, out dt);
                        if (success)
                        {
                            return dt;
                        }
                        else
                        {
                            throw new ParseException("Header field 'Date' parsing failed.");
                        }
                    }                   
                }
                else{
                    return DateTime.MinValue;
                }
            }

set{
                if(this.IsDisposed){
                    throw new ObjectDisposedException(this.GetType().Name);
                }

                if(value == DateTime.MinValue){
                    this.Header.RemoveAll("Date");
                }
                else{
                    MIME_h h = this.Header.GetFirst("Date");
                    if(h == null){
                        this.Header.Add(new MIME_h_Unstructured("Date",MIME_Utils.DateTimeToRfc2822(value)));
                    }
                    else{
                        this.Header.ReplaceFirst(new MIME_h_Unstructured("Date",MIME_Utils.DateTimeToRfc2822(value)));
                    }
                }
            }
        }


2、由于意外的数据包格式,握手失败
错误信息:[2013-05-04 10:13:54]    System.IO.IOException: 由于意外的数据包格式,握手失败。

在 LumiSoft.Net.TCP.TCP_Client.Connect(String host, Int32 port, Boolean ssl)

在 WHC.PlugInService.SmtpHelper.Send() 位置 ........\SmtpHelper.cs:行号 123

在 WHC.PlugInService.SendMailService.DataThreadHandle(MailSendConfigInfo info) 位置 ...............\SendMailService.cs:行号 66

错误原因:由于POP3的配置端口不正确导致,一般的端口必须严格按照正常的来填写。

邮件SMTP和POP3常用配置说明:

邮箱

 

Smtp服务器

 

Smtp端口

 

POP3服务器

 

POP3端口

 

使用SSL

 

Gmail.com

 

smtp.gmail.com

 

465

 

pop.gmail.com

 

995

 

true

 

QQ.com

 

smtp.qq.com

 

25

 

pop.qq.com

 

110

 

true

 

163.com

 

smtp.163.com

 

25

 

pop.163.com

 

110

 

false

 

Sina.com

 

smtp.sina.com

 

25

 

pop.sina.com

 

110

 

false

 

其他

 

smtp.test.com

 

25

 

pop.test.com

 

110

 

false

 

 3、邮件标题乱码问题

错误信息:标题出现类似=?utf-8?B?5rWL6K+V6YKu5Lu2?=

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjgxzs.html