-
-static TnyMimePart *
-add_body_part (TnyMsg *msg,
- const gchar *body,
- const gchar *content_type,
- gboolean has_attachments)
-{
- TnyMimePart *text_body_part = NULL;
- TnyStream *text_body_stream;
- TnyPlatformFactory *fact;
-
- fact = modest_tny_platform_factory_get_instance ();
-
- /* Create the stream */
- text_body_stream = TNY_STREAM (tny_camel_stream_new
- (camel_stream_mem_new_with_buffer
- (body, strlen(body))));
-
- /* Create body part if needed */
- if (has_attachments)
- text_body_part = tny_platform_factory_new_mime_part (fact);
- else
- text_body_part = TNY_MIME_PART(msg);
-
- /* Construct MIME part */
- tny_stream_reset (text_body_stream);
- tny_mime_part_construct_from_stream (text_body_part,
- text_body_stream,
- content_type);
- tny_stream_reset (text_body_stream);
-
- /* Add part if needed */
- if (has_attachments) {
- tny_mime_part_add_part (TNY_MIME_PART (msg), text_body_part);
- g_object_unref (G_OBJECT(text_body_part));
- }
-
- /* Clean */
- g_object_unref (text_body_stream);
-
- return text_body_part;
-}