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:
https://docs.aspose.com/email/net/working-with-attachments-and-embedded-objects/
In your case, you should save a document into a stream and then create attachment from this stream:
https://reference.aspose.com/email/net/aspose.email/attachment/
Best regards,