SmtpMail.AutoTextBody Property


Specifies the e-mail generates alternative text body for html body automatically.

[Visual Basic]
Public Property AutoTextBody As Boolean
[C#]
public bool AutoTextBody {get; set;}
[C++]
public: __property bool get_AutoTextBody();
public: __property void set_AutoTextBody(bool);
[JScript]
public function get AutoTextBody() : bool;
public function set AutoTextBody(bool);

Property Value

If HtmlBody is specified and TextBody is not specified, seting AutoTextBody to true indicates alternative text body for html body will be generated automatically.

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

[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.TextBody Property
SmtpMail.HtmlBody Property