- tny_msg_iface_add_part(new_msg, text_body_part);
-
- for (attachment = (GList *)attachments_list; attachment; attachment = attachment->next) {
- filename = attachment->data;
- attachment_filename = g_path_get_basename(filename);
- file = open(filename, O_RDONLY);
- attachment_stream = TNY_STREAM_IFACE(tny_stream_camel_new(
- camel_stream_fs_new_with_fd(file)));
-
+ if (attachments_list == NULL) {
+ tny_stream_iface_reset (text_body_stream);
+ tny_msg_mime_part_iface_construct_from_stream (TNY_MSG_MIME_PART_IFACE(new_msg),
+ text_body_stream, content_type);
+ tny_stream_iface_reset (text_body_stream);
+ } else {
+ text_body_part = TNY_MSG_MIME_PART_IFACE (tny_msg_mime_part_new(
+ camel_mime_part_new()));
+ tny_stream_iface_reset (text_body_stream);
+ tny_msg_mime_part_iface_construct_from_stream (text_body_part,
+ text_body_stream,
+ content_type);
+ tny_stream_iface_reset (text_body_stream);
+ tny_msg_iface_add_part(new_msg, text_body_part);
+ //g_object_unref (G_OBJECT(text_body_part));
+ }
+
+ for ( pos = (GList *)attachments_list;
+ pos;
+ pos = pos->next ) {
+ attachment = pos->data;
+ attachment_filename = modest_tny_attachment_get_name(attachment);
+ attachment_stream = modest_tny_attachment_get_stream(attachment);