3

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 accordance with RFC 822. Do we have some library/function in C/C++ which will do the job ?

Nands
  • 1,541
  • 2
  • 20
  • 33

3 Answers3

4

Mimetic works great ! it also takes care of non-standard mail headers.

Nands
  • 1,541
  • 2
  • 20
  • 33
2

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!

Mauro Bilotti
  • 5,628
  • 4
  • 44
  • 65
1

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.

Duane Moore
  • 926
  • 8
  • 5
  • Paid software, can't use it! Found an opensource solution http://codesink.org/mimetic_mime_library.html#snippets . trying it out now – Nands Feb 11 '11 at 06:06