MailBee.NET Objects 7.2

TextBodyPartCollection Class

Provides properties and methods for managing and examining the collection of TextBodyPart objects.

For a list of all members of this type, see TextBodyPartCollection Members.

System.Object
   System.Collections.CollectionBase
      MailBee.Mime.TextBodyPartCollection

[DefaultMember(MemberName="Item")]
public class TextBodyPartCollection : CollectionBase

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

To access text parts of the message, use MailMessage.BodyParts property. Also, MailMessage object provides BodyHtmlText and BodyPlainText properties for quick access to the HTML and plain-text body of the message.

Example

This sample loads the message from .EML file and displays the contents of all text parts of this message.

[C#]
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.Mime;

// The actual code (put it into a method of your class).
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
foreach (TextBodyPart textPart in msg.BodyParts)
{
    Console.WriteLine("Part type: " + textPart.AsMimePart.ContentType);
    Console.WriteLine(textPart.Text);
    Console.WriteLine();
}
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.Mime

' The actual code (put it into a method of your class).
' Load the message from file.
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
For Each textPart As TextBodyPart In msg.BodyParts
    Console.WriteLine("Part type: " & textPart.AsMimePart.ContentType)
    Console.WriteLine(textPart.Text)
    Console.WriteLine()
Next

Requirements

Namespace: MailBee.Mime

Assembly: MailBee.NET (in MailBee.NET.dll)

See Also

TextBodyPartCollection Members | MailBee.Mime Namespace | BodyParts | TextBodyPart