Hello -
We currently email XLS/PDF output as an email attachment, and are curious about sending HTML output as the body of an email. Has anyone tried this before, and is it possible? What I’d like to do is:
- Create a workbook with ASPose.Cells.
- Save the workbook as HTML.
- Send the HTML output as the body of an email.
Any help would be greatly appreciated .Thanks!
Sean Clauson
Hi Sean Clauson,
Well, I think you may save the workbook as html using Aspose.Cells APIs and attach it to the mail as an attachment if it works for your need. See the following sample code:
Sample code:
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Cell cell = worksheet.Cells[“A1”];
cell.PutValue(“testing2…”);
//Your code goes here.
MemoryStream ms = new MemoryStream();
workbook.Save(ms, FileFormatType.Html);
ms.Seek(0, SeekOrigin.Begin);
MailMessage message = new MailMessage("abc@aspose.com", "def@hotmail.com");
message.Subject = “Aspose Test”;
message.Body = “message body”;
message.Attachments.Add(new Attachment(ms, “newpost1.html”, “application/ms-excel”));
SmtpClient client = new SmtpClient();
client.Host = stringClientHost;
client.Send(message);
Thank you.