Hi
I'm trying to send a mail thru System.Net.Mail and I want it to use UTF-8 encoding for the Subject. So I tried this:
| MailMessagemail=newMailMessage(from,to); |
| mail.SubjectEncoding=Encoding.UTF8; |
| mail.Subject="åäö"; |
| mail.BodyEncoding=Encoding.UTF8; |
| mail.Body=body; |
| mail.IsBodyHtml=htmlmode; |
| |
| SmtpClientsmtp=newSmtpClient(); |
| smtp.Send(mail); |
But the result was: ï¿?ï¿?ï¿?/font>
So I took a look at the System.Net code and found the EncodeHeaderValue method in the System.Net.Mime.MimeBasePart class.
And in there I noticed two things, it starts of by creating the 'encoded-word' string. And if base64 encoding is used it does this.
| Base64Streamstream=newBase64Stream(-1); |
| stream.EncodeBytes(bytes,0,bytes.Length,true); |
| builder.Append(Encoding.ASCII.GetString(stream.WriteState.Buffer,0,stream.WriteState.Length)); |
So I wonder:
1. Should it really use Encoding.ASCII.GetString()? Shouldn't it be using the selected encoding, for example Encoding.UTF8.GetString().
2. An 'encoded-word' word can only be 75 characters long, including 'charset', 'encoding' and 'encoded-text'. But I can't figure out how you are creating multiple 'encoded-word's if needed.
3. Can any of the above cause the problem I'm having?
Thanks