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

Free Support Forum - aspose.com

Documents Embedding in an email

I would like to know how to embed a pdf/doc/xls file in an email and send it to the clients.


Thanks for considering Aspose.

You may first create an instance of MailMessage class and set its properties e.g. Subject, from, to and body and call AddAttachment() method to add an attachment.
Then use SmtpClient class to send this email. Sample code is given below:

// prepare the message
MailMessage msg = new MailMessage("from@gmail.com", "to@gmail.com");
msg.Subject = “test sending attachments”;
msg.AddAttachment(new Attachment(@“test.pdf”));
msg.AddAttachment(new Attachment(@“test.doc”));
msg.AddAttachment(new Attachment(@“test.xlsx”));
// send email
SmtpClient client = new SmtpClient(“smtp.gmail.com”, 587, "from@gmail.com", “pwd”);
client.EnableSsl = true;
client.SecurityMode = SmtpSslSecurityMode.Explicit;

For more details, please refer to the topics at http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/sending-email-messages-with-smtp.html.

Thanks for the reply, this works fine to send the files as attachments.

I wanted to embed the file content in the mail, not as an attachment.


I will get back to you with the required information shortly.