Mail.dll recognizes MIME entity type looking at its content-type header (MimeBase.ContentType
).
If it is set to text/* (e.g.: text/plain, text/xml) or is not set at all, MimeText
instance is created. Other classes are used for different content types (e.g. MimeCalendar
, MimeVCard
, MimeRfc822
,...).
For 'application/octet-stream' MimeData
is created.
Please note that a sender may use 'application/octet-stream', instead of more precise 'application/pdf'.
It's hard to tell from your questions what mimeText variable represents, but if you have MimeData
you have its Data
property and you can use it to access entity's bytes.
If somehow you know this entity contains XML data, you can easily create an XmlDocument
:
IMail email = ...;
MimeData attachment = email.Attachments[0];
byte[] data = attachment.Data;
There are multiple ways to create XmlDocument from byte array:
XmlDocument doc = new XmlDocument();
string xml = Encoding.UTF8.GetString(data);
doc.LoadXml(xml);
-or-
XmlDocument doc = new XmlDocument();
MemoryStream ms = new MemoryStream(data);
doc.Load(ms);
This assumes your data has UTF8 encoding which is the usual for XML.