+static void
+format_headers_message_part_json (GMimeMessage *message)
+{
+ void *ctx = talloc_new (NULL);
+ void *ctx_quote = talloc_new (ctx);
+ InternetAddressList *recipients;
+ const char *recipients_string;
+
+ printf ("%s: %s",
+ json_quote_str (ctx_quote, "From"),
+ json_quote_str (ctx_quote, g_mime_message_get_sender (message)));
+ recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
+ recipients_string = internet_address_list_to_string (recipients, 0);
+ if (recipients_string)
+ printf (", %s: %s",
+ json_quote_str (ctx_quote, "To"),
+ json_quote_str (ctx_quote, recipients_string));
+ recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
+ recipients_string = internet_address_list_to_string (recipients, 0);
+ if (recipients_string)
+ printf (", %s: %s",
+ json_quote_str (ctx_quote, "Cc"),
+ json_quote_str (ctx_quote, recipients_string));
+ printf (", %s: %s",
+ json_quote_str (ctx_quote, "Subject"),
+ json_quote_str (ctx_quote, g_mime_message_get_subject (message)));
+ printf (", %s: %s",
+ json_quote_str (ctx_quote, "Date"),
+ json_quote_str (ctx_quote, g_mime_message_get_date_as_string (message)));
+
+ talloc_free (ctx_quote);
+ talloc_free (ctx);
+}
+