#include <unistd.h>
#include <gmime/gmime.h>

int main (int argc, char **argv)
{
	GMimeStream *stream;
	
	g_mime_init ();

	stream = g_mime_stream_pipe_new (STDOUT_FILENO);
	
	GMimeMessage *reply = g_mime_message_new (1);

	g_mime_message_set_subject (reply, "foo", NULL);

	const char *subject = g_mime_message_get_subject (reply);

	fprintf (stderr, "stored subject = %s\n", subject);
	
	g_mime_object_write_to_stream (GMIME_OBJECT(reply), NULL, stream);

	
	g_object_unref (stream);
	
	g_mime_shutdown ();
	
	return 0;
}
