Hi,
Currently I’m testing an evaluation version of Aspose.Email. Currently I can only see encoded characters instead of the actual image I put in as an attachment. Also, when I set the message body to be html…it shows the html tags…not the actual data as it is rendered in a browser. (basically we have a form where the user can select the rows that they want to email from a gridview. We then use the string writer to grab the html of the rows they selected and coalesce this into an html string to put into the email body) Can give me some feedback? ( i have attached the email contents that i get from Aspose.Email, as well as the picture I put in as an attachment)
Here’s the code I used:
protected void mailSendButton_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter writer = new HtmlTextWriter(sw);
reportGrid.RenderBeginTag(writer);
foreach (GridViewRow row in reportGrid.Rows)
{
TableCell cellCheck = null;
for (int i = 0; i < row.Cells.Count; i++)
{
TableCell cell = row.Cells;
if (cell.Controls.Count > 0 && cell.Controls[0] is HtmlInputCheckBox)
{
cellCheck = cell;
}
}
if (cellCheck == null) continue;
HtmlInputCheckBox check = cellCheck.Controls[0] as HtmlInputCheckBox;
if (check.Checked)
{
row.RenderControl(writer);
}
}
reportGrid.RenderEndTag(writer);
Aspose.Email.Message msg = new Aspose.Email.Message();
msg.From = new Aspose.Email.Address("kshen@watchfire.com");
msg.ReplyTo = new Aspose.Email.Address("kshen@watchfire.com");
msg.AddAddress(new Aspose.Email.Address("kshen@watchfire.com"), Aspose.Email.Address.Type.To);
msg.Subject = “Broken Links Report”;
msg.Date = DateTime.Now;
msg.Confirmation = true;
msg.AllowRefusedAddresses = true;
Aspose.Email.TextHtmlBody htmlBody = new Aspose.Email.TextHtmlBody();
htmlBody.Content = Server.HtmlEncode(sb.ToString());
htmlBody.Charset = “UTF-8”;
Aspose.Email.AlternativeBody altBody = new Aspose.Email.AlternativeBody();
altBody.AddPart(htmlBody);
msg.Body = altBody;
Aspose.Email.Attachment embeddedImage = new Aspose.Email.Attachment(“c:\watchfirelogo.gif”);
msg.AddEmbeddedObject(embeddedImage);
msg.Send(new SmtpAccount(“1WFEMAIL”, 25, “kshen”, “hacknslash”), new ProgressMonitor());