Re: [gmime-devel] modifying a single header of a message on-disk



Excerpts from Gaute Hope's message of October 29, 2014 15:59:
Are there any examples on how to modify a single header of an existing
message without risking ending up with an inconsistent message? What
would be the best way to go about it?

I spoke too soon, this seems to do the trick. Although, it seems like
gmime cleans up the message (a diff between the result and the original
does not just contain the modified header).


 GMimeStream * f = g_mime_stream_file_new_for_path (path.c_str(),
     "r");
 GMimeParser * parser = g_mime_parser_new_with_stream (f);
 GMimeMessage * message = g_mime_parser_construct_message (parser);
 g_mime_object_set_header (GMIME_OBJECT(message), "HeaderName", "headervalue");

 GMimeStream * out = g_mime_stream_file_new_for_path ("/tmp/testmsg", "w");
 g_mime_object_write_to_stream (GMIME_OBJECT(message), out);

 g_mime_stream_flush (out);
 g_mime_stream_close (out);

 g_object_unref (message);
 g_object_unref (parser);
 g_mime_stream_close (f);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]