Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

August 1, 2007

Controllling the Content-Transfer-Encoding of the Email Body

The Chilkat Email component will automatically choose the best encoding and charset based on the characters used in a body. It auto-recognizes the language of characters. If a mix of languages is present, then utf-8 is chosen as the charset. Otherwise, the most commonly used charset for email for a particular language is automatically used.

Content-Transfer-Encoding: For Asian languages, base64 is the default encoding. For Western languages, quoted-printable is the default.

The Charset and transfer encoding can be manually set. To set the charset, simply set the Charset property to the name of the charset desired. For example, Japanese emails can be sent in "iso-2022-jp", "shift_jis", "euc-jp", "utf-8″, etc.

To set the content transfer encoding, call AddHeaderField("content-transfer-encoding","") to add or replace the Content-Transfer-Encoding header field, which forces a specific encoding of your choice. Here is a C# example:

            Chilkat.Email email = new Chilkat.Email();
	
            email.Subject = "à á â ã ä å";
            email.Body = "à á â ã ä å";
	
            textBox1.Text = textBox1.Text + "---- Default ----\r\n" + email.GetMime() + "\r\n\r\n";
	
            email.AddHeaderField("content-transfer-encoding", "8bit");
            textBox1.Text = textBox1.Text + "---- 8bit ----\r\n" + email.GetMime() + "\r\n\r\n";
	
            email.AddHeaderField("content-transfer-encoding", "base64");
            textBox1.Text = textBox1.Text + "---- base64 ----\r\n" + email.GetMime() + "\r\n\r\n";
	
            email.AddHeaderField("content-transfer-encoding", "quoted-printable");
            textBox1.Text = textBox1.Text + "---- quoted-printable ----\r\n" + email.GetMime() + "\r\n\r\n";

This is the program output:

---- Default ----
MIME-Version: 1.0
Date: Wed, 01 Aug 2007 16:31:24 -0500
Message-ID: <CHILKAT-MID-0f081b40-524e-fe68-1067-13feef4106ec@CK2007>
X-Mailer: Chilkat Software Inc (http://www.chilkatsoft.com)
X-Priority: 3 (Normal)
Content-Type: text/plain;
	 charset="iso-8859-1"
Subject: =?iso-8859-1?Q?=E0_=E1_=E2_=E3_=E4_=E5?=
Content-Transfer-Encoding: quoted-printable
	
=E0 =E1 =E2 =E3 =E4 =E5
	
---- 8bit ----
MIME-Version: 1.0
Date: Wed, 01 Aug 2007 16:31:24 -0500
Message-ID: <CHILKAT-MID-0f081b40-524e-fe68-1067-13feef4106ec@CK2007>
X-Mailer: Chilkat Software Inc (http://www.chilkatsoft.com)
X-Priority: 3 (Normal)
Content-Type: text/plain;
	 charset="iso-8859-1"
Subject: =?iso-8859-1?Q?=E0_=E1_=E2_=E3_=E4_=E5?=
Content-Transfer-Encoding: 8bit
	
à á â ã ä å
	
---- base64 ----
MIME-Version: 1.0
Date: Wed, 01 Aug 2007 16:31:24 -0500
Message-ID: <CHILKAT-MID-0f081b40-524e-fe68-1067-13feef4106ec@CK2007>
X-Mailer: Chilkat Software Inc (http://www.chilkatsoft.com)
X-Priority: 3 (Normal)
Content-Type: text/plain;
	 charset="iso-8859-1"
Subject: =?iso-8859-1?Q?=E0_=E1_=E2_=E3_=E4_=E5?=
Content-Transfer-Encoding: base64
	
4CDhIOIg4yDkIOU=
	
---- quoted-printable ----
MIME-Version: 1.0
Date: Wed, 01 Aug 2007 16:31:24 -0500
Message-ID: <CHILKAT-MID-0f081b40-524e-fe68-1067-13feef4106ec@CK2007>
X-Mailer: Chilkat Software Inc (http://www.chilkatsoft.com)
X-Priority: 3 (Normal)
Content-Type: text/plain;
	 charset="iso-8859-1"
Subject: =?iso-8859-1?Q?=E0_=E1_=E2_=E3_=E4_=E5?=
Content-Transfer-Encoding: quoted-printable
	
=E0 =E1 =E2 =E3 =E4 =E5
	


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.