lumisoft邮件内容中文乱码问题

Posted 程序园

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lumisoft邮件内容中文乱码问题相关的知识,希望对你有一定的参考价值。

修改MIME_b_Text.cs文件,红色字体为添加的部分,绿色为修改部分

private static Encoding m_pEncoding = Encoding.Default;

#region static method Parse

/// <summary>
/// Parses body from the specified stream
/// </summary>
/// <param name="owner">Owner MIME entity.</param>
/// <param name="defaultContentType">Default content-type for this body.</param>
/// <param name="stream">Stream from where to read body.</param>
/// <returns>Returns parsed body.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>stream</b>, <b>mediaType</b> or <b>stream</b> is null reference.</exception>
/// <exception cref="ParseException">Is raised when any parsing errors.</exception>
protected static new MIME_b Parse(MIME_Entity owner,MIME_h_ContentType defaultContentType,SmartStream stream)
{
if(owner == null){
throw new ArgumentNullException("owner");
}
if(defaultContentType == null){
throw new ArgumentNullException("defaultContentType");
}
if(stream == null){
throw new ArgumentNullException("stream");
}

MIME_b_Text retVal = null;
if(owner.ContentType != null){
retVal = new MIME_b_Text(owner.ContentType.TypeWithSubtype);
}
else{
retVal = new MIME_b_Text(defaultContentType.TypeWithSubtype);
}

Net_Utils.StreamCopy(stream,retVal.EncodedStream,32000);

m_pEncoding = stream.Encoding;

retVal.SetModified(false);

return retVal;
}

#endregion

 

#region method GetCharset

/// <summary>
/// Gets charset from Content-Type. If char set isn‘t specified, "ascii" is defined as default and it will be returned.
/// </summary>
/// <returns>Returns content charset.</returns>
/// <exception cref="ArgumentException">Is raised when Content-Type has not supported charset parameter value.</exception>
private Encoding GetCharset()
{
// RFC 2046 4.1.2. The default character set, US-ASCII.

if(this.Entity.ContentType == null || string.IsNullOrEmpty(this.Entity.ContentType.Param_Charset)){
//return Encoding.ASCII;
return m_pEncoding;
}
else{
// Handle custome/extended charsets, just remove "x-" from start.
if(this.Entity.ContentType.Param_Charset.ToLower().StartsWith("x-")){
return Encoding.GetEncoding(this.Entity.ContentType.Param_Charset.Substring(2));
}
// Cp1252 is not IANA reggistered, some mail clients send it, it equal to windows-1252.
else if(string.Equals(this.Entity.ContentType.Param_Charset,"cp1252",StringComparison.InvariantCultureIgnoreCase)){
return Encoding.GetEncoding("windows-1252");
}
else{
return Encoding.GetEncoding(this.Entity.ContentType.Param_Charset);
}
}
}

#endregion

以上是关于lumisoft邮件内容中文乱码问题的主要内容,如果未能解决你的问题,请参考以下文章

解决ZABBIX自定义邮件报警内容乱码问题

邮件内容经常出现乱码,用编码去转换也不行,如何解决?

java 接收邮件附件乱码

C#程序接收邮件 内容为乱码 求指教

我发送的邮件人家怎么看着是乱码??

使用Outlook 2003收到的邮件,中文内容全显示为问号怎么解决?