Free Support Forum - aspose.com

Email Document as attachment

Hi,


I have a C# method which returns a Document object, which I stream down to the client machine like this:

Document doc = CreateDocument();
doc.Save(Response, fileName.Text + “.doc”, ContentDisposition.Attachment, null);

Works perfectly.

However, my client has now requested the ability to email the Document as a mail attachment without saving it to the client machine or the webserver first, ideally using the AttachmentCollection of the MailMessage object. Is this possible?

Any assistance gratefully received.

Mark

Hi Mark,

Thanks for your request. Sure, you can attach the generated document as an attachment to an email. For example, you can use Aspose.Network to create, manage attachments and send emails:

http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/managing-email-attachments.html

In your case, you should save a document into a stream and then create attachment from this stream:

http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/aspose.network.mail.attachmentconstructor4.html

Best regards,