+1 vote

Is there a way to read an attachment rather than saving it to disk? I have a VB.Net application that needs to read XML attachments then process the data in them. I would rather do this in the same process rather than saving them to disk and having another thread read through them.

by

1 Answer

0 votes

Sure it is possible. You don't need to save attachments to disk before processing. Use MimeText.Text property:

IMail email = new MailBuilder()
    .CreateFromEml(imap.GetMessageByUID(uid));

foreach (MimeData mime in email.Attachments)
{
    if (mime.ContentType == ContentType.TextXml)
    {
        MimeText mimeText = mime as MimeText;

        XmlDocument doc = new XmlDocument();
        doc.LoadXml(mimeText.Text);
    }
}
by (296k points)
...