Dynamically add XML as an attatchment from Stream

U

UnglueD

Hello.

I've written an application that sends an email when complete. I
wish to attach an XML document with any custom errors that the program
encountered.

Initially I have done this:

If orderErrors.count > 0 Then
w = New StreamWriter(orderFile)
s.Serialize(w, orderErrors)
w.Close()
mail.Attachments.Add(New Attachment(orderFile))
End If

Where orderErrors is an Object which contains an XML serializable
array of error messages. It serializes fine and I have gotten it to
output to an absolute path on the filesystem. Then I attatch it to the
email to be sent.

What I would like to do is skip outputing it to an actual XML file on
the filesystem, and serialize it to a stream (which the Attatchments
framework allows) and send it.

I wish to do this because, I wish to publish just the .exe and have
it be used on different machines who will not have this directory
structure setup.

Thanks in advance!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top