{
int lineLength = 40; // 每行处理 40 个字节
Encoding encoding = Encoding.GetEncoding( charset ); // 取指定编码
byte[] buffer = encoding.GetBytes( s ); // 转换为字节码
string linebase64 ;
{
if( buffer.Length - i*lineLength >=lineLength )
linebase64 = Convert.ToBase64String( buffer, i*lineLength, lineLength );
else
linebase64 = Convert.ToBase64String( buffer, i*lineLength, buffer.Length - i*lineLength);
sb.Append( "=?" );
sb.Append( charset );
sb.Append( "?B?" );
sb.Append( linebase64 );
sb.Append( "?=\r\n\t" );
}
sb.Remove( sb.Length-3, 3); // 删除最后的换行符号
return sb.ToString();
}
// sb.Append("Subject: " + MailEncoder.ConvertHeaderToQP(cleanSubject.ToString(), charset) + "\r\n");
sb.Append("Subject: " + MailEncoder.ConvertHeaderToBase64( cleanSubject.ToString(), charset) + "\r\n");