  | MimeMessageBodyParts Property | 
            Get the body parts of the message.
            
Namespace: MimeKitAssembly: MimeKit (in MimeKit.dll) Version: 4.12.0
Syntax
Remarks
            Traverses over the MIME tree, enumerating all the 
MimeEntity objects,
            but does not traverse into the bodies of attached messages.
            
Exampleforeach (var bodyPart in message.BodyParts) {
    if (!bodyPart.IsAttachment)
        continue;
    if (bodyPart is MessagePart) {
        var fileName = attachment.ContentDisposition?.FileName;
        var rfc822 = (MessagePart) attachment;
        if (string.IsNullOrEmpty (fileName))
            fileName = "attached-message.eml";
        using (var stream = File.Create (fileName))
            rfc822.Message.WriteTo (stream);
    } else {
        var part = (MimePart) attachment;
        var fileName = part.FileName;
        using (var stream = File.Create (fileName))
            part.Content.DecodeTo (stream);
    }
}
See Also