Mail.TextBody Property


Gets the plain/text body of the e-mail message.

[Visual Basic]
Public Property TextBody As String
[C#]
public string TextBody {get;}
[C++]
public: __property String^ get_TextBody();
[JScript]
public function get TextBody() : String;

Property Value

A String value indicating the text body of the e-mail message.

Remarks

If the email doesn't have a html body part, HtmlBody returns a html body converted from text body part; If the email doesn't have a text body part, TextBody returns a text body converted from html body.

Example

[C#]
Mail oMail = new Mail("TryIt");

oMail.Load( "c:\\test.eml", false );

Console.WriteLine( "text body:" );
Console.WriteLine( oMail.TextBody );
Console.WriteLine( "" );
Console.WriteLine( "html body:" );
Console.WriteLine( oMail.HtmlBody );


/*if the test.eml has both text and html part,

From: <>
Subject: (Trial Version)
Date: Thu, 23 Mar 2006 15:04:18 +0800
MIME-Version: 1.0
Content-Type: multipart/alternative;
        boundary="----=MailPart0000_0010_044A2F14"

This is a multi-part message in MIME format.

------=MailPart0000_0010_044A2F14
Content-Type: text/plain;
        charset="utf-8"
Content-Transfer-Encoding: quoted-printable

this is a text body

------=MailPart0000_0010_044A2F14
Content-Type: text/html;
        charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html><body>this is a html body</body></html>

------=MailPart0000_0010_044A2F14--


then output

text body:
this is a text body

html body:
<html><body>this is a html body</body></html>


if the test.eml has only text part,

From: <>
Subject: (Trial Version)
Date: Thu, 23 Mar 2006 15:04:18 +0800
MIME-Version: 1.0
Content-Type: text/plain;
        charset="utf-8"
Content-Transfer-Encoding: quoted-printable

test body

then output

text body:
test body

html body:
test body<br>

if the test.eml has only html part,
From: <>
Subject: (Trial Version)
Date: Thu, 23 Mar 2006 15:04:18 +0800
MIME-Version: 1.0
Content-Type: text/html;
        charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html><body>this is a html body</body></html>


then output

text body:
this is a html body

html body:
<html><body>this is a html body</body></html>
*/


See Also

Mail.From Property
Mail.To Property
Mail.Cc Property
Mail.OriginalBodyFormat Property
Mail.HtmlBody Property
Mail.Subject Property

Online Tutorials

Parse Email in C# - Tutorial
Parse winmail.dat(TNEF) in C# - Tutorial
Parse Email in VB.NET - Tutorial
Parse winmail.dat(TNEF) in VB.NET - Tutorial
Parse Email in C++/CLI - Tutorial
Parse winmail.dat(TNEF) in C++/CLI - Tutorial