Bestcomy.net blog

Coding for funny

导航

OpenSMTP 发送中文名称附件产生乱码问题

Posted on 2005-01-21 20:16  bestcomy  阅读(3551)  评论(4编辑  收藏  举报
最近用OpenSMTPsohu免费信箱发邮件,发现中文名称的附件在sohu信箱收到是附件名称会是乱码,检查了一下源码,发现问题应该是出在OpenSmtp.Mail.Smtp的私有方法WriteToStream,修改后的代码如下:
private void WriteToStream(ref NetworkStream nw, string line)
        
{
            
try
            
{
                
//    byte[] arrToSend = Encoding.ASCII.GetBytes(line);
                byte[] arrToSend = Encoding.Default.GetBytes(line);        //modified by bestcomy
                nw.Write(arrToSend, 0, arrToSend.Length);
                
//Console.WriteLine("[client]:" + line);
                LogMessage(line, "[client]: ");
            }

            
catch(System.Exception)
            
{
                
throw new SmtpException("Write to Stream threw an System.Exception");
            }

        }

把源代码导到SharpDevelop重新编译了一下就好使了,我用SharpDevelop作的OpenSMTP工程:
http://www.upload4asp.net/download.aspx?filename=T3BlblNtdHAucmFy