old_cid = tny_mime_part_get_content_id (old_attachment);
attachment_part = copy_mime_part (old_attachment, err);
if (attachment_part != NULL) {
- tny_mime_part_set_header_pair (attachment_part, "Content-Disposition",
- add_inline?"inline":"attachment");
+ if (add_inline) {
+ tny_mime_part_set_header_pair (attachment_part, "Content-Disposition",
+ "inline");
+ } else {
+ const gchar *filename;
+ filename = tny_mime_part_get_filename (old_attachment);
+ if (filename)
+ tny_mime_part_set_filename (attachment_part, filename);
+ else
+ tny_mime_part_set_header_pair (attachment_part, "Content-Disposition",
+ "attachment");
+ }
tny_mime_part_set_transfer_encoding (TNY_MIME_PART (attachment_part), "base64");
ret = tny_mime_part_add_part (TNY_MIME_PART (part), attachment_part);
if (old_cid)
g_free (header_content_type_lower);
g_free (header_content_type);
return NULL;
- }
+ }
g_free (header_content_type_lower);
g_free (header_content_type);
content_type = g_strstrip (content_type);
content_type_lower = g_ascii_strdown (content_type, -1);
g_free (content_type);
- is_text_part = g_str_has_prefix (content_type_lower, "text/");
+ is_text_part =
+ g_str_has_prefix (content_type_lower, "text/") ||
+ g_str_has_prefix (content_type_lower, "message/rfc822");
g_free (content_type_lower);
/* if this part cannot be a supported body return NULL */
if (!is_text_part) {