MailBee.NET Objects 4.0

TextBodyPart.IsOriginal Property

Indicates if the text part came with the message or it was added automatically during parsing the message.

public bool IsOriginal {get;}

Property Value

true if the text part is the original part of the message; otherwise, false.

Remarks

If the message does not have plain-text or HTML body, Parser object can be configured to tell MailBee to generate such a body (in fact, create the corresponding TextBodyPart) during parsing. MailBee will place automatically created parts of the message into BodyParts collection.

Also, the developer can manually add a text part into BodyParts collection using its methods.

The scenarios listed above will produce TextBodyPart objects having IsOriginal set to false.

Example

This sample loads the message from .EML file, generates HTML body from the plain-text body, and reports whether HTML and plain-text parts are original.

[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)

// Load plain-text message and make HTML body automatically.
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\PlainTextEmail.eml");
msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfPlain;

// Report plain-text and HTML parts origin.
Console.WriteLine("Plain part IsOriginal = " + msg.BodyParts.Plain.IsOriginal.ToString());
Console.WriteLine("HTML part IsOriginal = " + msg.BodyParts.Html.IsOriginal.ToString());
[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 plain-text message and make HTML body automatically.
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\PlainTextEmail.eml")
msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfPlain

' Report plain-text and HTML parts origin.
Console.WriteLine("Plain part IsOriginal = " & msg.BodyParts.Plain.IsOriginal.ToString())
Console.WriteLine("HTML part IsOriginal = " & msg.BodyParts.Html.IsOriginal.ToString())

See Also

TextBodyPart Class | MailBee.Mime Namespace | Parser