Click or drag to resize

MimeIterator Class

An iterator for a MIME tree structure.
Inheritance Hierarchy

Namespace: MimeKit
Assembly: MimeKit (in MimeKit.dll) Version: 4.3.0
public class MimeIterator : IEnumerator<MimeEntity>, 
	IDisposable, IEnumerator

The MimeIterator type exposes the following members.

Public methodCode exampleMimeIterator Initialize a new instance of the MimeIterator class.
Public propertyCode exampleCurrent Get the current entity.
Public propertyDepth Get the depth of the current entity.
Public propertyMessage Get the top-level message.
Public propertyCode exampleParent Get the parent of the current entity.
Public propertyPathSpecifier Get the path specifier for the current entity.
Public methodDispose Release all resources used by the MimeIterator object.
Protected methodDispose(Boolean) Release the unmanaged resources used by the MimeIterator and optionally releases the managed resources.
Public methodEquals
(Inherited from Object)
Protected methodFinalize Releases unmanaged resources and performs other cleanup operations before the MimeIterator is reclaimed by garbage collection.
(Overrides ObjectFinalize)
Public methodGetHashCode
(Inherited from Object)
Public methodGetType
(Inherited from Object)
Protected methodMemberwiseClone
(Inherited from Object)
Public methodCode exampleMoveNext Advance the iterator to the next depth-first entity of the tree structure.
Public methodMoveTo Advance to the entity specified by the path specifier.
Public methodReset Reset the iterator to its initial state.
Public methodToString
(Inherited from Object)
Walks the MIME tree structure of a MimeMessage in depth-first order.
var attachments = new List<MimePart> ();
var multiparts = new List<Multipart> ();

using (var iter = new MimeIterator (message)) {
    // collect our list of attachments and their parent multiparts
    while (iter.MoveNext ()) {
        var multipart = iter.Parent as Multipart;
        var part = iter.Current as MimePart;

        if (multipart != null && part != null && part.IsAttachment) {
            // keep track of each attachment's parent multipart
            multiparts.Add (multipart);
            attachments.Add (part);

// now remove each attachment from its parent multipart...
for (int i = 0; i < attachments.Count; i++)
    multiparts[i].Remove (attachments[i]);
See Also