Index: /branches/2.2.0.1/expressoMail1_2/js/main.js
===================================================================
--- /branches/2.2.0.1/expressoMail1_2/js/main.js	(revision 4252)
+++ /branches/2.2.0.1/expressoMail1_2/js/main.js	(revision 4258)
@@ -1659,5 +1659,5 @@
 	textArea.name = "body";
 	body = document.getElementById("body_"+ID);
-	textArea.value += ( ( mail_as_plain ) ? body.previousSibling.value : ( '<body>\r\n' + body.contentWindow.document.body.innerHTML + '\r\n</body>' ) );
+	textArea.value = ( ( mail_as_plain ) ? body.previousSibling.value : ( '<body>\r\n' + body.contentWindow.document.body.innerHTML + '\r\n</body>' ) );
 	var input_folder = document.createElement("INPUT");
 	input_folder.style.display='none';
@@ -1903,5 +1903,5 @@
 		withImage = false;
 
-	var rt_checkbox = Element('viewsource_rt_checkbox_' + ID);
+	var rt_checkbox = Element('viewsource_rt_checkbox_' + border_id);
 	if (rt_checkbox == null)
 		return false;
@@ -1930,4 +1930,7 @@
 	var handler_save_msg = function(data){ return_save(data,this.tmp_border_id,this.tmp_folder_name,this.tmp_folder_id,this.message_id); }
 
+        var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + border_id );
+	mail_as_plain = ( mail_as_plain ) ? mail_as_plain.checked : false;
+
 	var textArea = document.createElement("TEXTAREA");
 	textArea.style.display='none';
@@ -1936,7 +1939,5 @@
 	if (! body)
 		return;
-	textArea.value += '<body>\r\n';
-	textArea.value += body.contentWindow.document.body.innerHTML;
-	textArea.value += '\r\n</body>';
+	textArea.value = ( ( mail_as_plain ) ? body.previousSibling.value : ( '<body>\r\n' + body.contentWindow.document.body.innerHTML + '\r\n</body>' ) );
 	var input_folder = document.createElement("INPUT");
 	input_folder.style.display='none';
@@ -1964,4 +1965,9 @@
 	form.appendChild(input_msgid);
 	form.appendChild(input_insertImg);
+
+        var mail_type = form.appendChild( document.createElement( 'input' ) );
+	mail_type.name = 'type';
+	mail_type.type = 'hidden';
+	mail_type.value = ( mail_as_plain ) ? 'plain' : 'html';
 
 	cExecuteForm ("$this.imap_functions.save_msg", form, handler_save_msg,border_id);
Index: /branches/2.2.0.1/expressoMail1_2/js/draw_api.js
===================================================================
--- /branches/2.2.0.1/expressoMail1_2/js/draw_api.js	(revision 4253)
+++ /branches/2.2.0.1/expressoMail1_2/js/draw_api.js	(revision 4258)
@@ -2616,25 +2616,4 @@
 
 	tr_menu_new_message.appendChild(td_menu_new_message);
-
-        if ( ! expresso_offline )
-	{
-		var text_plain = td_menu_new_message.appendChild(
-			document.createElement( 'span' )
-		).appendChild(
-			document.createTextNode( ' | ' )
-		).parentNode.appendChild(
-			document.createElement( 'input' )
-		).parentNode.appendChild(
-			document.createTextNode( get_lang('Send this mail as text plain') + '.')
-		).previousSibling;
-		text_plain.setAttribute( 'tabIndex', '-1' );
-		text_plain.id = 'textplain_rt_checkbox_' + ID ;
-		text_plain.type = "checkbox";
-		text_plain.onclick = function ()
-		{
-			RichTextEditor.plain( ( ! this.checked ) ? this.checked : mobile_device || ( this.checked = confirm( 'The text format will be lost.' ) ) );
-			document.getElementById( 'viewsource_rt_checkbox_' + ID ).parentNode.style.display = ( this.checked ) ? 'none' : '';
-		};
-	}
 
 	tbody_menu_new_message.appendChild(tr_menu_new_message);
@@ -3165,4 +3144,26 @@
 	tr5.appendChild(td5);
 	tr5.appendChild(td_return_receipt);
+
+        if ( ! expresso_offline )
+	{
+		var text_plain = td_return_receipt.appendChild(
+			document.createElement( 'span' )
+		).appendChild(
+			document.createTextNode( ' | ' )
+		).parentNode.appendChild(
+			document.createTextNode( get_lang('Send this mail as text plain') + '.')
+		).parentNode.appendChild(
+			document.createElement( 'input' )
+		);
+		text_plain.setAttribute( 'tabIndex', '-1' );
+		text_plain.id = 'textplain_rt_checkbox_' + ID ;
+		text_plain.type = "checkbox";
+		text_plain.onclick = function ()
+		{
+			RichTextEditor.plain( this.checked );
+			document.getElementById( 'viewsource_rt_checkbox_' + ID ).parentNode.style.display = ( this.checked ) ? 'none' : '';
+		};
+	}
+
 	tbody_message.appendChild(tr5);
 	if (parseInt(preferences.use_important_flag))
Index: /branches/2.2.0.1/expressoMail1_2/js/rich_text_editor.js
===================================================================
--- /branches/2.2.0.1/expressoMail1_2/js/rich_text_editor.js	(revision 4252)
+++ /branches/2.2.0.1/expressoMail1_2/js/rich_text_editor.js	(revision 4258)
@@ -166,5 +166,12 @@
 		}
 		else{
+                        var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + this.id );
+
 			html = document.createTextNode( editor.contentWindow.document.body.innerHTML );
+                        html = html.nodeValue.replace( /<br\s*\/?>/mg, "\n" ).replace( /(<([^>]+)>)/ig, '' ).replace( /^[\n ]+|[\n ]+$/g, '' );
+
+			if ( ! mobile_device && html != '' && ! ( mail_as_plain.checked = confirm( 'The text format will be lost.' ) ) )
+				return false;
+
 			this.table.style.visibility="hidden";
 			editor.contentWindow.document.body.innerHTML = '';
@@ -174,5 +181,5 @@
 			textarea.style.height = '300px';
 			textarea.style.fontSize = '12pt';
-			textarea.innerHTML = html.nodeValue.replace( /<br\s*\/?>/mg, "\n" ).replace( /(<([^>]+)>)/ig, '' );
+			textarea.innerHTML = html;
 
 			editor.style.width = '0px';
