+1 vote

My company is planning to buy mail.dll from your company.
we have some problems; we must analyze each part of message (MessageParts:text/html, multipart/....). but we dont find this.

Have you any way to do this?


1 Answer

0 votes
Best answer

Of course you can do that.

Are you sure, that you need to traverse entire MIME tree on your own?
IMail instance exposes Attachments collection, and Text and Html properties.

If you need to examine MIME tree yourself use IMail.Document.Root property.
It returns MimeBase instance (MimeMultipart or MimeData depending on the message). MimeMultipart class has Parts property which contain all MIME parts that this entity stores.

Here's the code:

public void Process(IMail email)
    MimeBase root = email.Document.Root;

public void Process(MimeBase root)
    if (root is MimeMultipart)
        ProcessMultipart((MimeMultipart) root);
        ProcesMimeData((MimeData) root);

private void ProcessMultipart(MimeMultipart root)
    foreach (MimeBase part in root.Parts)

private void ProcesMimeData(MimeData root)
    byte[] data = root.Data;
    string fileName = root.SafeFileName;
by (298k points)