I've a C code where I fetch headers for all mails in the inbox via imap issuing UID FETCH 1:* (FLAGS BODY[HEADER]) command. Due to special authentication requirements I cannot use a standard imap library like vmime or libetpan. I need to parse the mail header values in accorda开发者_如何学运维nce with RFC 822. Do we have some library/function in C/C++ which will do the job ?
Mimetic works great ! it also takes care of non-standard mail headers.
Here is an example using mimetic:
void MailServer::PrintMimeStructure(MimeEntity* pMe)
{
Header& h = pMe->header();
if(h.hasField("subject"))
cout << "<subject>" << h.field("subject").value() << "</subject>" <<
endl;
if(h.hasField("from"))
cout << "<from>" << h.field("from").value() << "</from>" <<
endl;
if(h.hasField("to"))
cout << "<to>" << h.field("to").value() << "</to>" <<
endl;
if(h.hasField("message-id"))
cout << "<message-id>" << h.field("message-id").value() << "</message-id>" <<
endl;
if(h.hasField("date"))
cout << "<date>" << h.field("date").value() << "</date>" <<
endl;
}
This is what you need? Hope it helps!
A long time ago in a galaxy far, far away, I used the MIME++ library, now supported by Hunny Software: http://www.hunnysoft.com/mimepp/
It worked great at the time.
精彩评论