Click or drag to resize
MimeKit

MimeIterator Class

An iterator for a MIME tree structure.
Inheritance Hierarchy
SystemObject
  MimeKitMimeIterator

Namespace:  MimeKit
Assembly:  MimeKit (in MimeKit.dll) Version: 2.0.7.0
Syntax
C#
public class MimeIterator : IEnumerator<MimeEntity>, 
	IDisposable, IEnumerator

The MimeIterator type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleMimeIterator
Initializes a new instance of the MimeIterator class.
Top
Properties
  NameDescription
Public propertyCode exampleCurrent
Gets the current entity.
Public propertyDepth
Gets the depth of the current entity.
Public propertyMessage
Gets the top-level message.
Public propertyCode exampleParent
Gets the parent of the current entity.
Public propertyPathSpecifier
Gets the path specifier for the current entity.
Top
Methods
  NameDescription
Public methodDispose
Releases all resources used by the MimeIterator object.
Protected methodDispose(Boolean)
Releases the unmanaged resources used by the MimeIterator and optionally releases the managed resources.
Public methodEquals
Determines whether the specified object is equal to the current object.
(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
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleMoveNext
Advances the iterator to the next depth-first entity of the tree structure.
Public methodMoveTo
Advances to the entity specified by the path specifier.
Public methodReset
Resets the iterator to its initial state.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
Walks the MIME tree structure of a MimeMessage in depth-first order.
Examples
C#
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