SmtpMail.TextBody Property


Gets or sets the text body of the e-mail message.

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

Property Value

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

Remarks

If HtmlBody is not specified and TextBody is specified, the email body is plain text format; If HtmlBody is specified and TextBody is not specified, the email body is text/html format; If both of HtmlBody and TextBody is specified, the email body is multipart/alternative format.
To generate special body part, please refer to MimePart class.

Example

[Visual Basic, C#] To get the full samples of EASendMail, please refer to Samples section.

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

oMail.HtmlBody = "<html><body>this is a test</body></html>";
oMail.TextBody = "";

Console.WriteLine( System.Text.Encoding.ASCII.GetString(oMail.EncodedContent));

//Output
/*
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 test

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

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

------=MailPart0000_0010_044A2F14--
*/

oMail.HtmlBody = "<html><body>this is a test</body></html>";
oMail.TextBody = "plain body text";

Console.WriteLine( System.Text.Encoding.ASCII.GetString(oMail.EncodedContent));

//Output
/*
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

plain body text

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

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

------=MailPart0000_0010_044A2F14--
*/

oMail.TextBody = "test body";
oMail.HtmlBody = "";

Console.WriteLine( System.Text.Encoding.ASCII.GetString(oMail.EncodedContent));

//Output
/*
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
*/

oMail.HtmlBody = "<html><body>this is a test</body></html>";
oMail.TextBody = "";
oMail.AutoTextBody = false;

Console.WriteLine( System.Text.Encoding.ASCII.GetString(oMail.EncodedContent));
//Output
/*
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 test</body></html>
*/

See Also

SmtpMail.AutoTextBody Property
SmtpMail.HtmlBody Property
SmtpMail.ImportTextBody Method

Online Examples

C# - Send Email with Inline Images
VB - Send Email with Inline Images
C++/CLI - Send Email with Inline Images

Online Tutorials

Send Email in C# - Tutorial
Send Email in VB - Tutorial
Send Email in Managed C++/CLI - Tutorial