diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 9228aec..ccbf531 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -801,20 +801,23 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje
 	gpointer parent;
 	EMFormat *emf = (EMFormat *) efh;
 	CamelMessageInfo *mi = NULL;
-	CamelMessageContentInfo *ci = NULL;
-	GFileInfo *fileinfo;
-	guint32 size;
+	guint32 size = 0;
 
 	/* FIXME: handle default shown case */
 	d(printf("adding attachment button/content\n"));
 
 	mi = camel_folder_summary_uid (emf->folder->summary, emf->uid);
-	ci = camel_folder_summary_guess_content_info (mi, ((CamelDataWrapper *)pobject->part)->mime_type);
-	if (ci) {
-		size = ci->size;
-		/* what if its not encoded in base64 ? is it a case to consider? */
-		if (ci->encoding && !g_ascii_strcasecmp (ci->encoding, "base64"))
-			size = size/1.37;
+	if (mi) {
+		const CamelMessageContentInfo *ci;
+
+		ci = camel_folder_summary_guess_content_info (mi, camel_mime_part_get_content_type (pobject->part));
+		if (ci) {
+			size = ci->size;
+			/* what if its not encoded in base64 ? is it a case to consider? */
+			if (ci->encoding && !g_ascii_strcasecmp (ci->encoding, "base64"))
+				size = size/1.37;
+		}
+		camel_message_info_free (mi);
 	}
 
 	info = (struct _attach_puri *)em_format_find_puri((EMFormat *)efh, pobject->classid);
@@ -843,6 +846,8 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje
 		info->attachment, (GAsyncReadyCallback)
 		e_attachment_load_handle_error, parent);
 	if (size != 0) {
+		GFileInfo *fileinfo;
+
 		fileinfo = e_attachment_get_file_info (info->attachment);
 		g_file_info_set_size (fileinfo, size);
 		e_attachment_set_file_info (info->attachment, fileinfo);
