您的位置:首页 > 运维架构

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

2005-01-21 20:16 417 查看
最近用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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: