GMimeStream* stream = g_mime_stream_mem_new_with_buffer(static_cast<char*>(ptr),dataSize); g_mime_stream_seek (stream, 0, GMIME_STREAM_SEEK_END); g_mime_stream_write (stream, "\n", 1); // or \r\n if the buffer you are giving it uses CRLF line endings g_mime_stream_reset (stream); Then pass it off to the parser like you do in the code you pasted. Hope that helps, Jeff