Click or drag to resize
MimeKit

MimeIteratorMoveNext Method

Advance the iterator to the next depth-first entity of the tree structure.

Namespace: MimeKit
Assembly: MimeKit (in MimeKit.dll) Version: 4.3.0
Syntax
C#
public bool MoveNext()

Return Value

Boolean
true if the iterator was successfully advanced to the next entity; otherwise, false.

Implements

IEnumeratorMoveNext
Remarks
After an iterator is created or after the Reset method is called, an iterator is positioned before the first entity of the message, and the first call to the MoveNext method moves the iterator to the first entity of the message. If MoveNext advances beyond the last entity of the message, MoveNext returns false. When the iterator is at this position, subsequent calls to MoveNext also return false until Reset is called.
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