We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Failed to open PDF file- sent as an email attachement

Dear team,

I have the error message as open pdf from email attachment. "Adobe Reader could not open 'filename.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment amd was not correctly decoded"

My codes as below

byte[] content = Encoding.ASCII.GetBytes("

test
Test3");

MemoryStream stream = new MemoryStream(content);

MemoryStream outStream = new MemoryStream();

var pdf = new Aspose.Pdf.Pdf();

pdf.BindHTML(stream);

pdf.Save(outStream);

System.Net.Mail.MailMessage mailMessage = new MailMessage("fromemail@yahoo.com", "toEmail@yahoo.com");

mailMessage.Attachments.Add(new Attachment(outStream, "test.pdf"));
System.Net.Mail.SmtpClient client = new SmtpClient();
mailMessage.Body = "test";
mailMessage.Subject = "test";
client.Send(mailMessage);

How can I send email with pdf attachemnt?. I would not save pdf file to the file system before sending as attachment email.