Free Support Forum -

Email Document as attachment


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.


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:

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

Best regards,