I have a C # form, the input of which I am going to turn into an XML document for attaching to an email sent to myself. So far, I have an XDocument, which I believe is complete, and I also figured out how to attach .txt to MailMessage with:
MailMessage.Attachments.Add(new Attachment("[...]\test.txt"));
I understand that I could use
XDocument.Save("[...]\formData.xml");
to save the file and then
MailMessage.Attachments.Add(new Attachment("[...]\formData.xml"));
load and attach it, but it seems wasteful.
Does anyone have a better way around this? I suppose there should be a way to attach an XDocument without going into a file system like this ...
source share