Attachment showing up emtpy

Received : 2007/11/23 15:56:08
Message : When I save to a stream, then try to attach to an email, I receive the email, but the attachment is empty. Could you please help? I've tried everything, but I cannot get this to work. Thank you kindly for your assistance. Here's the pertinent excerpt from my code:

System.IO.MemoryStream s = new System.IO.MemoryStream();
workbook.Save(s, FileFormatType.Default)

System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add(strMailTo);
msg.From = new MailAddress(strMailFrom);
msg.Subject = "Test email";
msg.Body = "Test email with attached report";
msg.Attachments.Add(new Attachment(s, "report.xls", "application/vnd.ms-excel"));

SmtpClient smtp = new SmtpClient(strSmtpServer);
smtp.Credentials = new System.Net.NetworkCredential(strUserName, strPassword);
smtp.Send(msg);


This message was posted using Aspose.Live 2 Forum

Hi,

Thanks for considering Aspose.

We will check and get back to you soon.

Thank you.

Hi,

Thanks for considering Aspose.

I think you may try:

1. Try to seek to the origin for the memory stream before attachment. E.g., memorystream.Seek(0, SeekOrigin.Begin);

2. Alternatively, you may try to save the excel file to disk first bofore attaching.

Thank you.