Index: camel/providers/imap/ChangeLog
===================================================================
--- camel/providers/imap/ChangeLog	(revision 10198)
+++ camel/providers/imap/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2009-04-08  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #478239
+
+	* camel-imap-folder.c: (imap_get_message):
+	Check whether message has really attachment part when claiming so.
+
 2009-03-09  Matthew Barnes  <mbarnes@redhat.com>
 
 	* camel-imap-summary.c (camel_imap_summary_new):
Index: camel/providers/imap/camel-imap-folder.c
===================================================================
--- camel/providers/imap/camel-imap-folder.c	(revision 10198)
+++ camel/providers/imap/camel-imap-folder.c	(working copy)
@@ -3006,6 +3006,14 @@ done:
 					camel_folder_summary_touch (mi->info.summary);
 			}
 		}
+
+		if ((mi->info.flags & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (msg)) {
+			mi->info.flags = mi->info.flags & ~CAMEL_MESSAGE_ATTACHMENTS;
+			mi->info.dirty = TRUE;
+
+			if (mi->info.summary)
+				camel_folder_summary_touch (mi->info.summary);
+		}
 	}
 fail:
 	camel_message_info_free(&mi->info);
Index: camel/providers/local/camel-mbox-folder.c
===================================================================
--- camel/providers/local/camel-mbox-folder.c	(revision 10198)
+++ camel/providers/local/camel-mbox-folder.c	(working copy)
@@ -214,6 +214,9 @@ mbox_append_message(CamelFolder *folder,
 
 	d(printf("Appending message: uid is %s\n", camel_message_info_uid(mi)));
 
+	if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message))
+		camel_message_info_set_flags (mi, CAMEL_MESSAGE_ATTACHMENTS, 0);
+
 	output_stream = camel_stream_fs_new_with_name(lf->folder_path, O_WRONLY | O_APPEND | O_LARGEFILE, 0666);
 	if (output_stream == NULL) {
 		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
Index: camel/providers/local/ChangeLog
===================================================================
--- camel/providers/local/ChangeLog	(revision 10198)
+++ camel/providers/local/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2009-04-08  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #478239
+
+	* camel-mbox-folder.c: (mbox_append_message):
+	* camel-maildir-folder.c: (maildir_append_message):
+	* camel-mh-folder.c: (mh_append_message):
+	Check whether message has really attachment part when claiming so.
+
 2009-03-01  Srinivasa Ragavan  <sragavan@novell.com>
 
 	* camel/providers/local/camel-local-folder.c: Fix for a deadlock,
Index: camel/providers/local/camel-maildir-folder.c
===================================================================
--- camel/providers/local/camel-maildir-folder.c	(revision 10198)
+++ camel/providers/local/camel-maildir-folder.c	(working copy)
@@ -176,7 +176,10 @@ maildir_append_message (CamelFolder *fol
 	mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
 	if (camel_exception_is_set (ex))
 		return;
-	
+
+	if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message))
+		camel_message_info_set_flags (mi, CAMEL_MESSAGE_ATTACHMENTS, 0);
+
 	mdi = (CamelMaildirMessageInfo *)mi;
 
 	d(printf("Appending message: uid is %s filename is %s\n", camel_message_info_uid(mi), mdi->filename));
Index: camel/providers/local/camel-mh-folder.c
===================================================================
--- camel/providers/local/camel-mh-folder.c	(revision 10198)
+++ camel/providers/local/camel-mh-folder.c	(working copy)
@@ -140,7 +140,10 @@ mh_append_message (CamelFolder *folder, 
 	mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
 	if (camel_exception_is_set (ex))
 		return;
-	
+
+	if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message))
+		camel_message_info_set_flags (mi, CAMEL_MESSAGE_ATTACHMENTS, 0);
+
 	d(printf("Appending message: uid is %s\n", camel_message_info_uid(mi)));
 	
 	/* write it out, use the uid we got from the summary */
Index: camel/camel-mime-message.c
===================================================================
--- camel/camel-mime-message.c	(revision 10198)
+++ camel/camel-mime-message.c	(working copy)
@@ -1169,6 +1169,47 @@ camel_mime_message_build_mbox_from (Came
 	return ret;
 }
 
+static gboolean
+find_attachment (CamelMimeMessage *msg, CamelMimePart *part, void *data)
+{
+	const char *disp;
+	gboolean *found = (gboolean *)data;
+
+	g_return_val_if_fail (part != NULL, FALSE);
+
+	disp = camel_mime_part_get_disposition (part);
+
+	if (disp) {
+		CamelContentDisposition *cd = camel_content_disposition_decode (disp);
+
+		if (cd) {
+			*found = (cd->disposition && g_ascii_strcasecmp (cd->disposition, "attachment") == 0);
+
+			camel_content_disposition_unref (cd);
+		}
+	}
+
+	return ! (*found);
+}
+
+/**
+ * camel_mime_message_has_attachment:
+ * @message: a #CamelMimeMessage object
+ *
+ * Returns whether message contains at least one attachment part.
+ **/
+gboolean
+camel_mime_message_has_attachment (CamelMimeMessage *message)
+{
+	gboolean found = FALSE;
+
+	g_return_val_if_fail (message != NULL, FALSE);
+
+	camel_mime_message_foreach_part (message, find_attachment, &found);
+
+	return found;
+}
+
 static void
 cmm_dump_rec(CamelMimeMessage *msg, CamelMimePart *part, int body, int depth)
 {
Index: camel/camel-mime-message.h
===================================================================
--- camel/camel-mime-message.h	(revision 10198)
+++ camel/camel-mime-message.h	(working copy)
@@ -128,6 +128,8 @@ CamelMimePart              *camel_mime_m
 
 char                       *camel_mime_message_build_mbox_from    (CamelMimeMessage           *message);
 
+gboolean		    camel_mime_message_has_attachment     (CamelMimeMessage           *message);
+
 void camel_mime_message_dump(CamelMimeMessage *msg, int body);
 
 G_END_DECLS
Index: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 10199)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2009-04-08  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #478239
+
+	* camel-mime-message.h: (camel_mime_message_has_attachment):
+	* camel-mime-message.c: (camel_mime_message_has_attachment),
+	(find_attachment): New helper function to check whether
+	message contains any 'attachment' part.
+
 2009-04-07  Milan Crha  <mcrha@redhat.com>
 
 	** Fix for bug #575084
