[Mono-bugs] [Bug 346162] New: Sys.Net.Mail: Encoding problems when using AlternateViews

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Dec 5 07:17:20 EST 2007


https://bugzilla.novell.com/show_bug.cgi?id=346162


           Summary: Sys.Net.Mail: Encoding problems when using
                    AlternateViews
           Product: Mono: Class Libraries
           Version: SVN
          Platform: i686
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: juraj at hotfeet.ch
         QAContact: mono-bugs at ximian.com
          Found By: ---


When sending MailMessages containing AlternateViews, the encoding is messed up
(and the charset is never stated in the mail). I've tested this with the very
latest code from SVN (r90741).

(Also note that MS.NET replaces an empty Subject with "No subject".)

Test case:
==========
using System;
using System.Text;
using System.Net.Mail;

class Test {
        static void Main(string[] args) {
                MailMessage msg = new MailMessage(args[1], args[2]);
                msg.Body =
                        "<html><body>Test: H\u00e4ll\u00f6!" +
                        "</body></html>";

                msg.IsBodyHtml = true;
                msg.BodyEncoding = Encoding.GetEncoding("ISO-8859-1");

                msg.AlternateViews.Add(
                        AlternateView.CreateAlternateViewFromString(
                                "Test: H\u00e4ll\u00f6!",
                                Encoding.GetEncoding("ISO-8859-1"),
                                "text/plain"
                        )
                );

                SmtpClient smtp = new SmtpClient(args[0]);
                smtp.Send(msg);

                Console.WriteLine(msg.Body);
        }
}


Usage:
======
mono MailTest.exe [smtp hostname] [from] [to]

Result Mono:
============
Date: Wed, 05 Dec 2007 12:56:10 +01:00
From: test at hotfeet.ch
To: js at hotfeet.ch
Subject: 
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary=--boundary_0_537bb184-5012-4b33-b13b-38f3265d72b5
Message-Id: <20071205115610.22B994F3FBB at mercury.hotfeet.ch>
X-Evolution-Source: imap://js%40hotfeet.ch@mail.hotfeet.ch/

--
content-type: multipart/alternative;
boundary=--boundary_0_537bb184-5012-4b33-b13b-38f3265d72b5

----boundary_0_537bb184-5012-4b33-b13b-38f3265d72b5
content-type: text/html
content-transfer-encoding: quoted-printable

<html><body>Test: H?ll?!</body></html>

----boundary_0_537bb184-5012-4b33-b13b-38f3265d72b5
content-type: text/plain
content-transfer-encoding: quoted-printable

Test: H?ll?!

----boundary_0_537bb184-5012-4b33-b13b-38f3265d72b5--

Result .NET
===========
mime-version: 1.0
from: test at hotfeet.ch
to: js at hotfeet.ch
date: 5 Dec 2007 12:59:22 +0100
content-type: multipart/mixed;
boundary=--boundary_0_bebbe2e1-1dea-4743-ac23-5570e728cc87
Message-Id: <20071205115916.408204F3FBB at mercury.hotfeet.ch>
X-Evolution-Source: imap://js%40hotfeet.ch@mail.hotfeet.ch/
Subject: No Subject


----boundary_0_bebbe2e1-1dea-4743-ac23-5570e728cc87
content-type: multipart/alternative;
boundary=--boundary_1_95731698-9abb-48db-a8ad-8ae18935dac9


----boundary_1_95731698-9abb-48db-a8ad-8ae18935dac9
content-type: text/plain; charset=iso-8859-1
content-transfer-encoding: quoted-printable

<html><body>Test: H=E4ll=F6!</body></html>
----boundary_1_95731698-9abb-48db-a8ad-8ae18935dac9
content-type: text/plain; charset=iso-8859-1
content-transfer-encoding: quoted-printable

Test: H=E4ll=F6!
----boundary_1_95731698-9abb-48db-a8ad-8ae18935dac9--

----boundary_0_bebbe2e1-1dea-4743-ac23-5570e728cc87--


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list