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: 4.7.1
Syntax
C#
public class MimeIterator : IEnumerator<MimeEntity>, 
	IDisposable, IEnumerator

The MimeIterator type exposes the following members.

Constructors
 NameDescription
Public methodCode exampleMimeIterator Initialize a new instance of the MimeIterator class.
Top
Properties
 NameDescription
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.
Top
Methods
 NameDescription
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)
Top
Remarks
Walks the MIME tree structure of a MimeMessage in depth-first order.
Example
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