+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?

by

1 Answer

0 votes
 
Best answer

Of course you can do that.

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

2.
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;
    Process(root);
}

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

private void ProcessMultipart(MimeMultipart root)
{
    foreach (MimeBase part in root.Parts)
    {
        Process(part);
    }
}

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