Using Aspose.Cells with Aspose.Network.Mail

Hello, I am trying to use Aspose.Cells to create an excel workbook from a data set and then save to a stream and attach to an outgoing mail message using Aspose.Network.Mail. I have no problem saving the file to a local drive, but when I just try to use the stream I get the attachment to send, but the spreadsheet is blank. Here is some code....can someone tell what I am doing wrong? Thanks!

MemoryStream memoryStream = ExportDataToMemoryStream(dataSet);

Attachment attachment = new Attachment(memoryStream, "Results.xls", "application/vnd.ms-excel");

message.Attachments.Add(attachment); //Addition MailMessage code not included

public static MemoryStream ExportDataToMemoryStream(DataSet data)

{

Workbook excel = CreateSpreadsheet(data); //CreateSpreadsheet is the method that returns a Workbook

MemoryStream memoryStream = new MemoryStream();

excel.Save(memoryStream, FileFormatType.Default);

//have also tried excel.SaveToStream()

return memoryStream;

}

Hello, Please try to seek the memory stream to the begining before passing it to the Attachment constructor.

Thanks,

Thanks, that worked!