Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.541
diff -u -8 -p -r1.541 e-msg-composer.c
--- composer/e-msg-composer.c	18 Sep 2006 17:21:36 -0000	1.541
+++ composer/e-msg-composer.c	7 Nov 2006 06:48:50 -0000
@@ -57,17 +57,16 @@
 #include <glib/gstdio.h>
 
 #include <gtk/gtk.h>
 
 #include <gconf/gconf.h>
 #include <gconf/gconf-client.h>
 
 #include <libgnome/gnome-exec.h>
-#include <libgnome/gnome-help.h>
 #include <libgnome/gnome-i18n.h>
 #include <libgnomeui/gnome-uidefs.h>
 #include <libgnomeui/gnome-window-icon.h>
 
 #include <bonobo/bonobo-exception.h>
 #include <bonobo/bonobo-moniker-util.h>
 #include <bonobo/bonobo-stream-memory.h>
 #include <bonobo/bonobo-ui-util.h>
@@ -344,17 +343,17 @@ get_text (Bonobo_PersistStream persist, 
 	}
 	
 	CORBA_exception_free (&ev);
 	
 	stream_mem = BONOBO_STREAM_MEM (stream);
 	text = g_byte_array_new ();
 	g_byte_array_append (text, stream_mem->buffer, stream_mem->pos);
 	bonobo_object_unref (BONOBO_OBJECT (stream));
-	
+		
 	return text;
 }
 
 #define LINE_LEN 72
 
 static CamelTransferEncoding
 best_encoding (GByteArray *buf, const char *charset)
 {
@@ -604,22 +603,23 @@ build_message (EMsgComposer *composer, g
 		camel_object_unref (stream);
 		
 		stream = (CamelStream *) filter_stream;
 		filter = camel_mime_filter_charset_new_convert ("UTF-8", iconv_charset);
 		camel_stream_filter_add (filter_stream, (CamelMimeFilter *) filter);
 		camel_object_unref (filter);
 	}
 	
-	/* construct the content object */
+	/* construct the content object for text/plain encoding */
 	plain = camel_data_wrapper_new ();
 	camel_data_wrapper_construct_from_stream (plain, stream);
 	camel_object_unref (stream);
 	
 	camel_data_wrapper_set_mime_type_field (plain, type);
+	camel_data_wrapper_set_mime_type (plain, "text/plain; charset=utf-8");
 	camel_content_type_unref (type);
 	
 	if (p->send_html) {
 		CORBA_Environment ev;
 		clear_current_images (composer);
 		
 		if (save_html_object_data) {
 			CORBA_exception_init (&ev);
@@ -5156,16 +5156,77 @@ e_msg_composer_add_inline_image_from_mim
 	camel_object_ref (part);
 	
 	location = camel_mime_part_get_content_location (part);
 	if (location) {
 		g_hash_table_insert (p->inline_images_by_url,
 				     g_strdup (location), part);
 	}
 }
+
+/* Stub for helping in printing of mails */
+CamelMimeMessage * e_msg_composer_get_message_print (EMsgComposer *composer, gboolean save_html_object_data)
+{
+	CamelMimeMessage *msg, *temp_msg;
+	gboolean old_flags[4];
+	gboolean old_send_html;
+	EMsgComposer *temp_composer;
+	
+	EMsgComposerPrivate *p;
+	GString *flags;
+	int i;
+	
+	/* build message & create a new composer object from it which we'll use in building print/preview msg */
+	temp_msg = build_message (composer, save_html_object_data);
+	temp_composer = e_msg_composer_new_with_message(temp_msg);
+	
+	p = temp_composer->priv;
+	
+	/* create printable mail as HTML */
+	old_send_html = p->send_html;
+	p->send_html = TRUE;
+	old_flags[0] = p->pgp_sign;
+	p->pgp_sign = FALSE;
+	old_flags[1] = p->pgp_encrypt;
+	p->pgp_encrypt = FALSE;
+	old_flags[2] = p->smime_sign;
+	p->smime_sign = FALSE;
+	old_flags[3] = p->smime_encrypt;
+	p->smime_encrypt = FALSE;
+	
+	msg = build_message (temp_composer, save_html_object_data);
+	e_msg_composer_delete (temp_composer);
+	
+	/* Revert back message's original settings */
+	p->send_html = old_send_html;
+	p->pgp_sign = old_flags[0];
+	p->pgp_encrypt = old_flags[1];
+	p->smime_sign = old_flags[2];
+	p->smime_encrypt = old_flags[3];
+	
+	/* build_message() set this to text/html since we set p->send_html to
+	   TRUE before calling e_msg_composer_get_message() */
+	if (!p->send_html)
+		flags = g_string_new("text/plain");
+	else
+		flags = g_string_new("text/html");
+
+	/* This should probably only save the setting if it is
+	 * different from the from-account default? */
+	for (i=0;i<4;i++) {
+		if (old_flags[i])
+			g_string_append_printf(flags, ", %s", emc_draft_format_names[i]);
+	}
+
+	camel_medium_set_header (CAMEL_MEDIUM (msg), "X-Evolution-Format", flags->str);
+	g_string_free(flags, TRUE);	
+	
+	return msg;
+}
+
 
 
 /**
  * e_msg_composer_get_message:
  * @composer: A message composer widget
  * 
  * Retrieve the message edited by the user as a CamelMimeMessage.  The
  * CamelMimeMessage object is created on the fly; subsequent calls to this
Index: composer/e-msg-composer.h
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
retrieving revision 1.96
diff -u -8 -p -r1.96 e-msg-composer.h
--- composer/e-msg-composer.h	7 Dec 2005 08:29:51 -0000	1.96
+++ composer/e-msg-composer.h	7 Nov 2006 06:48:51 -0000
@@ -181,13 +181,16 @@ void			 e_msg_composer_insert_paragraph_
 void			 e_msg_composer_insert_paragraph_after		 (EMsgComposer *composer);
 void			 e_msg_composer_delete				 (EMsgComposer *composer);
 gchar*			 e_msg_composer_resolve_image_url 		 (EMsgComposer *composer, gchar *url);
 CamelMimePart*		 e_msg_composer_url_requested 			 (EMsgComposer *composer, gchar *url);
 
 EMsgComposerHdrs*	 e_msg_composer_get_hdrs			 (EMsgComposer *composer);
 void			 e_msg_composer_set_saved			 (EMsgComposer *composer);
 
+/* Stub for helping in printing of mails */
+CamelMimeMessage* 	e_msg_composer_get_message_print 		(EMsgComposer *composer, gboolean save_html_object_data);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 
 #endif /* ___E_MSG_COMPOSER_H__ */
Index: plugins/print-message/print-message.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/print-message/print-message.c,v
retrieving revision 1.2
diff -u -8 -p -r1.2 print-message.c
--- plugins/print-message/print-message.c	24 Aug 2005 03:14:10 -0000	1.2
+++ plugins/print-message/print-message.c	7 Nov 2006 06:49:35 -0000
@@ -78,17 +78,18 @@ org_gnome_print_message (EPlugin *ep, EM
        	EMsgComposer *composer = (EMsgComposer *)t->target.widget;
 	struct _print_data *data;
 	GtkDialog *dialog;
 	
 	data = g_malloc0(sizeof(*data));
 	data->config = e_print_load_config ();
 	data->preview = 0;
 	
-	data->msg = e_msg_composer_get_message (composer, 1);
+	data->msg = e_msg_composer_get_message_print (composer, 1);
+	
 	dialog = (GtkDialog *)e_print_get_dialog_with_config (_("Print Message"), GNOME_PRINT_DIALOG_COPIES, data->config);
 	gtk_dialog_set_default_response(dialog, GNOME_PRINT_DIALOG_RESPONSE_PRINT);
 	e_dialog_set_transient_for ((GtkWindow *) dialog, (GtkWidget *) composer);
 	g_signal_connect(dialog, "response", G_CALLBACK(print_response), data);
 	gtk_widget_show((GtkWidget *)dialog);
 	
 }
 
@@ -99,14 +100,14 @@ org_gnome_print_preview (EPlugin *ep, EM
 {
   	EMsgComposer *composer = (EMsgComposer *)t->target.widget;
 	struct _print_data *data;
 	
 	data = g_malloc0(sizeof(*data));
 	data->config = e_print_load_config ();
 	data->preview = 0;
 	
-	data->msg = e_msg_composer_get_message (composer, 1);
+	data->msg = e_msg_composer_get_message_print (composer, 1);
 
 	print_response(NULL, GNOME_PRINT_DIALOG_RESPONSE_PREVIEW, data);
 }
 
 
