if (priv->body_plain != NULL
&& priv->body_html != NULL)
{
+ CamelMultipart *mp_alt;
+
+ if (priv->attachments == NULL)
+ {
+ mp_alt = mp;
+ }
+ else
+ {
+ mp_alt = camel_multipart_new ();
+ camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (mp_alt), "multipart/alternative");
+ camel_multipart_set_boundary (mp_alt, NULL);
+ }
+
part = camel_mime_part_new ();
camel_mime_part_set_content (part, priv->body_plain, strlen (priv->body_plain), "text/plain; charset=\"UTF-8\"");
- camel_multipart_add_part (mp, part);
+ camel_multipart_add_part (mp_alt, part);
g_object_unref (part);
part = camel_mime_part_new ();
camel_mime_part_set_content (part, priv->body_html, strlen (priv->body_html), "text/html; charset=\"UTF-8\"");
- camel_multipart_add_part (mp, part);
+ camel_multipart_add_part (mp_alt, part);
g_object_unref (part);
+
+ if (priv->attachments != NULL)
+ {
+ GOutputStream *ostream;
+
+ gpointer data;
+ gulong data_size;
+
+ ostream = g_memory_output_stream_new_resizable ();
+
+ camel_data_wrapper_write_to_output_stream_sync (CAMEL_DATA_WRAPPER (mp_alt), ostream, NULL, NULL);
+
+ g_object_get (G_OBJECT (ostream),
+ "data", &data,
+ "data-size", &data_size,
+ NULL);
+
+ part = camel_mime_part_new ();
+ camel_mime_part_set_content (part, data, data_size, g_strdup_printf ("multipart/alternative; %s",
+ camel_multipart_get_boundary (mp_alt)));
+ camel_multipart_add_part (mp, part);
+ g_object_unref (part);
+
+ g_output_stream_close (ostream, NULL, NULL);
+ }
}
else
{
GError *error;
GFileInfo *file_info;
CamelStream *cstream;
- GInputStream *istream;
attachs = priv->attachments;
while (attachs != NULL)