Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.540
diff -u -r1.540 e-msg-composer.c
--- composer/e-msg-composer.c	6 Aug 2006 13:59:04 -0000	1.540
+++ composer/e-msg-composer.c	4 Sep 2006 08:04:26 -0000
@@ -4284,11 +4284,12 @@
 		CamelContentType *content_type;
 		CamelDataWrapper *content;
 		CamelMimePart *mime_part;
+		gboolean found = FALSE;
 		
 		mime_part = camel_multipart_get_part (multipart, i);
 		content_type = camel_mime_part_get_content_type (mime_part);
 		content = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
-		
+
 		if (CAMEL_IS_MULTIPART (content)) {
 			CamelMultipart *mp;
 			
@@ -4307,7 +4308,8 @@
 		} else if (camel_content_type_is (content_type, "text", "html")) {
 			/* text/html is preferable, so once we find it we're done... */
 			text_part = mime_part;
-			break;
+			if (e_msg_composer_get_send_html (composer))
+				break;
 		} else if (camel_content_type_is (content_type, "text", "*")) {
 			/* anyt text part not text/html is second rate so the first
 			   text part we find isn't necessarily the one we'll use. */
Index: mail/em-format.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format.c,v
retrieving revision 1.52
diff -u -r1.52 em-format.c
--- mail/em-format.c	20 Apr 2006 16:35:32 -0000	1.52
+++ mail/em-format.c	4 Sep 2006 08:04:27 -0000
@@ -1203,6 +1203,30 @@
 	}
 }
 
+static gboolean
+emf_format_match (const char *format, const char *mime)
+{
+	char **flags;
+	int j;
+	gboolean ret = FALSE;
+
+	if (!format || !mime)
+		return FALSE;
+
+	while (*format && camel_mime_is_lwsp(*format))
+		format++;
+
+	flags = g_strsplit(format, ", ", 0);
+	for (j=0;flags[j];j++) {
+		if (g_ascii_strcasecmp(flags[j], mime) == 0) {
+			ret = TRUE;
+		}
+	}
+	g_strfreev(flags);
+
+	return ret;
+}
+
 /* RFC 1740 */
 static void
 emf_multipart_alternative(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
@@ -1210,12 +1234,14 @@
 	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part);
 	int i, nparts, bestid;
 	CamelMimePart *best = NULL;
+	const char *format;
 
 	if (!CAMEL_IS_MULTIPART(mp)) {
 		em_format_format_source(emf, stream, part);
 		return;
 	}
 
+	format = camel_medium_get_header (CAMEL_MEDIUM (part), "X-Evolution-Format");
 	/* as per rfc, find the last part we know how to display */
 	nparts = camel_multipart_get_number(mp);
 	for (i = 0; i < nparts; i++) {
@@ -1229,8 +1255,9 @@
 		/*if (want_plain && !strcmp (mime_type, "text/plain"))
 		  return part;*/
 
-		if (em_format_find_handler(emf, mime_type)
-		    || (best == NULL && em_format_fallback_handler(emf, mime_type))) {
+		if (emf_format_match (format, mime_type) ||
+			(best == NULL  && (em_format_find_handler(emf, mime_type)
+		    || em_format_fallback_handler(emf, mime_type)))) {
 			best = part;
 			bestid = i;
 		}
