Bug 39864 - Sending an email with IsBodyHtml = true, and a single text/html AlternateView containing a LinkedResource does not include the LinkedResource binary in the email.
Summary: Sending an email with IsBodyHtml = true, and a single text/html AlternateView...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 4.0.0
Hardware: All Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-03-23 12:22 UTC by Nikki Locke
Modified: 2016-04-08 15:30 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test program to reproduce (2.00 KB, text/plain)
2016-03-23 12:22 UTC, Nikki Locke
Details

Description Nikki Locke 2016-03-23 12:22:59 UTC
Created attachment 15495 [details]
Test program to reproduce

Description of Problem:
Sending an email with IsBodyHtml = true, and a single text/html AlternateView containing a LinkedResource does not include the LinkedResource binary in the email.

Steps to reproduce the problem:
1. Compile the attached program, and run with arguments:

email address
graphic file name
[login name for email server]
[password for email server]
[mail server]
[port to connect to]
[use ssl (true|false)]

2. Study the email content - note that the graphic file is not included

Actual Results (run under mono):

[More headers omitted for brevity]
Date: Wed, 23 Mar 2016 12:13:34 +0000
Subject: Test email
MIME-Version: 1.0
Content-Type: text/html; charset=Windows-1252
Content-Transfer-Encoding: quoted-printable


<img src=3D"cid:jumbologo.jpg" /> This is a test email with an image






Expected Results (run under Microsoft .Net):

[More headers omitted for brevity]
Date: 23 Mar 2016 12:08:27 +0000
Subject: Test email
Content-Type: multipart/related;
 boundary=--boundary_1_e74a5413-3938-4b07-b7a8-a3e5bcaa8ae3; type="text/html"



----boundary_1_e74a5413-3938-4b07-b7a8-a3e5bcaa8ae3
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<img src=3D"cid:jumbologo.jpg" /> This is a test email with an im=
age
----boundary_1_e74a5413-3938-4b07-b7a8-a3e5bcaa8ae3
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-ID: <jumbologo.jpg>

/9j/4AAQSkZJRgABAAEAYABgAAD/4RCyRXhpZgAATU0AKgAAAAgAAodpAAQAAAABAAAI
[more encoded text omitted for brevity]
----boundary_1_e74a5413-3938-4b07-b7a8-a3e5bcaa8ae3--



How often does this happen? 
When run under Mono.

Additional Information:
Comment 1 Jeffrey Stedfast 2016-04-06 18:03:14 UTC
I would recommend using MailKit instead: https://github.com/jstedfast/MailKit

Eventually what will probably happen is that the current System.Net.Mail implementation will be completely replaced with the code from Microsoft's referencesource, but I'm assuming that if you are seeing this bug, then the offending class hasn't been replaced (yet).
Comment 2 Andi McClure 2016-04-08 15:30:23 UTC
As Jeffery said: If you check out the source to mono using git you will find the checkout contains both the Mono Project version of System.Net.Mail.MailMessage:

./mcs/class/System/System.Net.Mail/MailMessage.cs

And the Microsoft.NET version, which apparently lacks the bug:

./external/referencesource/System/net/System/Net/mail/MailMessage.cs

Apparently, the Mono build includes the Mono Project version rather than the .NET version. We would like to replace the Mono Project version with the .NET version-- we have already done this for MIME-- but this is not high priority for us so it will probably not happen soon. If you are not able to wait, here are two options you have:

- Yank out the System/Net/mail source code from referencesource and include it directly into your repository.
- You could build a fixed version of Mono yourself. If you edit `./mcs/class/System/System.dll.sources` , you will find a series of lines beginning with `System.Net.Mail/` . This is how the Mono build decides which classes to include in System.dll. If you replace the remaining `System.Net.Mail/` lines with references to the appropriate classes in `../../../external/referencesource/System/net/System/Net/mail` and rebuild Mono, this should fix your problem (although some testing or fiddling with the System.Net code might be necessary). If you do this, we would be happy to integrate a pull request containing the fix at https://github.com/mono/mono .

Note You need to log in before you can comment on or make changes to this bug.