J
julito
Hi
I got the next problem, in the following code I want to send 3 pics (pic1,
pic2, pic3) in a html table. But when I send the message the user who
receives this message look a table with three repeated images. Exactly the
first pic in add to AlternateViews collection.
Somebody can help me?
My CODE:
string fromAddress = "(e-mail address removed)";
string toAddress = "(e-mail address removed)";
MailMessage mailMessage = new MailMessage(fromAddress, toAddress);
mailMessage.Subject = "Text";
string html = @"<html>
<body>
<table border=1>
<tr><td colspan=3>header</td></tr>
<tr><td colspan=3><br></td></tr>
<tr><td><img src=cid: pic1/><br></td>
<td><img src=cid: pic2/><br></td>
<td><img src=cid: pic3/><br></td>
</tr>
<tr><td colspan=3>footer</td></tr>
</table>
</body>
</html>";
AlternateView av1 =
AlternateView.CreateAlternateViewFromString(html, null,
System.Net.Mime.MediaTypeNames.Text.Html);
string strImageUrl1 = @"c:\pic-1.jpg";
LinkedResource pic1 = new LinkedResource(strImageUrl1,
System.Net.Mime.MediaTypeNames.Image.Jpeg);
pic1.ContentId = "pic1";
pic1.TransferEncoding = TransferEncoding.Base64;
AlternateView av2 =
AlternateView.CreateAlternateViewFromString(html, null,
System.Net.Mime.MediaTypeNames.Text.Html);
string strImageUrl2 = @"c:\pic-2.jpg";
LinkedResource pic2 = new LinkedResource(strImageUrl2,
System.Net.Mime.MediaTypeNames.Image.Jpeg);
pic2.ContentId = "pic2";
pic2.TransferEncoding = TransferEncoding.Base64;
AlternateView av3 =
AlternateView.CreateAlternateViewFromString(html, null,
System.Net.Mime.MediaTypeNames.Text.Html);
string strImageUrl3 = @"c:\pic-3.jpg";
LinkedResource pic3 = new LinkedResource(strImageUrl3,
System.Net.Mime.MediaTypeNames.Image.Jpeg);
pic3.ContentId = "pic3";
pic3.TransferEncoding = TransferEncoding.Base64;
av1.LinkedResources.Add(pic1);
av2.LinkedResources.Add(pic2);
av3.LinkedResources.Add(pic3);
mailMessage.AlternateViews.Add(av1);
mailMessage.AlternateViews.Add(av2);
mailMessage.AlternateViews.Add(av3);
mailMessage.IsBodyHtml = true;
SmtpClient mailSender = new SmtpClient("smtpclient.server.com");
//use this if you are in the development server
mailSender.Send(mailMessage);
Thanks for All
I got the next problem, in the following code I want to send 3 pics (pic1,
pic2, pic3) in a html table. But when I send the message the user who
receives this message look a table with three repeated images. Exactly the
first pic in add to AlternateViews collection.
Somebody can help me?
My CODE:
string fromAddress = "(e-mail address removed)";
string toAddress = "(e-mail address removed)";
MailMessage mailMessage = new MailMessage(fromAddress, toAddress);
mailMessage.Subject = "Text";
string html = @"<html>
<body>
<table border=1>
<tr><td colspan=3>header</td></tr>
<tr><td colspan=3><br></td></tr>
<tr><td><img src=cid: pic1/><br></td>
<td><img src=cid: pic2/><br></td>
<td><img src=cid: pic3/><br></td>
</tr>
<tr><td colspan=3>footer</td></tr>
</table>
</body>
</html>";
AlternateView av1 =
AlternateView.CreateAlternateViewFromString(html, null,
System.Net.Mime.MediaTypeNames.Text.Html);
string strImageUrl1 = @"c:\pic-1.jpg";
LinkedResource pic1 = new LinkedResource(strImageUrl1,
System.Net.Mime.MediaTypeNames.Image.Jpeg);
pic1.ContentId = "pic1";
pic1.TransferEncoding = TransferEncoding.Base64;
AlternateView av2 =
AlternateView.CreateAlternateViewFromString(html, null,
System.Net.Mime.MediaTypeNames.Text.Html);
string strImageUrl2 = @"c:\pic-2.jpg";
LinkedResource pic2 = new LinkedResource(strImageUrl2,
System.Net.Mime.MediaTypeNames.Image.Jpeg);
pic2.ContentId = "pic2";
pic2.TransferEncoding = TransferEncoding.Base64;
AlternateView av3 =
AlternateView.CreateAlternateViewFromString(html, null,
System.Net.Mime.MediaTypeNames.Text.Html);
string strImageUrl3 = @"c:\pic-3.jpg";
LinkedResource pic3 = new LinkedResource(strImageUrl3,
System.Net.Mime.MediaTypeNames.Image.Jpeg);
pic3.ContentId = "pic3";
pic3.TransferEncoding = TransferEncoding.Base64;
av1.LinkedResources.Add(pic1);
av2.LinkedResources.Add(pic2);
av3.LinkedResources.Add(pic3);
mailMessage.AlternateViews.Add(av1);
mailMessage.AlternateViews.Add(av2);
mailMessage.AlternateViews.Add(av3);
mailMessage.IsBodyHtml = true;
SmtpClient mailSender = new SmtpClient("smtpclient.server.com");
//use this if you are in the development server
mailSender.Send(mailMessage);
Thanks for All