[Mono-bugs] [Bug 516455] New: System.Net.Mail error on alternativeviews mono 2.4
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Jun 25 09:30:59 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=516455
Summary: System.Net.Mail error on alternativeviews mono 2.4
Classification: Mono
Product: Mono: Class Libraries
Version: 2.4.x
Platform: Other
OS/Version: Linux
Status: NEW
Severity: Major
Priority: P5 - None
Component: System
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: sniper666666 at hotmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: Component Test
When creating a System.Net.Mail and sending it with alternateView the email
body is empty if a file is attached. The email is sent with body if no file is
attached the body will be displayed for the alternateviews but images attached
to the alternateVievs is not pressent. I know there have been similar problems
in earlier versions back in december 2007. To test this run this site but
change the smtp to your own as well as email and path on random image attached
(Locally on Windows the email is sent fine in all cases.:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
/////// EDIT THIS TO YOUR EMAIL
string mEmail = "XXXX at XXX";
/////// EDIT TO PATH FOR IMAGE
string mPictureAddressAfterBasePath = "/images/mail_logo.gif";
////// EDIT THIS TO SMTPSERVER
string mSmtpServer = "XXXXXXX";
mail.To.Add(mEmail);
mail.From = new System.Net.Mail.MailAddress(mEmail);
mail.Subject = "Test";
mail.BodyEncoding = System.Text.Encoding.UTF8;
string mBody = "<html><body><div>Tester <img src=\"cid:header_left\"
align=\"left\"></div></body></html>";
// PLAIN / HTML
System.Net.Mail.AlternateView plainView =
System.Net.Mail.AlternateView.CreateAlternateViewFromString("TEST PLAIN", null,
"text/plain");
System.Net.Mail.AlternateView htmlView =
System.Net.Mail.AlternateView.CreateAlternateViewFromString(mBody, new
System.Net.Mime.ContentType("text/html"));
//create the LinkedResource (embedded image)
System.Net.Mail.LinkedResource logo = new
System.Net.Mail.LinkedResource(System.AppDomain.CurrentDomain.BaseDirectory +
mPictureAddressAfterBasePath);
logo.ContentId = "header_left";
//add the LinkedResource to the appropriate view
htmlView.LinkedResources.Add(logo);
//add the views
mail.AlternateViews.Add(plainView);
mail.AlternateViews.Add(htmlView);
Random mRandom = new Random(); ;
// insert attachment (Data)
byte[] mBytes = new byte[8];
mRandom.NextBytes(mBytes);
System.IO.MemoryStream stream = new System.IO.MemoryStream(mBytes);
mail.Attachments.Add(new System.Net.Mail.Attachment(stream, "Test.mp3",
"audio/x-mp3"));
System.Net.Mail.SmtpClient mSmtpClient = new
System.Net.Mail.SmtpClient(mSmtpServer);
mail.IsBodyHtml = true;
mSmtpClient.Send(mail);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
--
Configure bugmail: http://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