Extract Message-id from Message Header Grails

I need message-id of an email from message header,What are the ways to extract message id from message Header.I am using grails mail plugin.

Answers


The message id is the first element of a mail header. So a way to achieve this is to output the e-mail content in a String and then extract the message-id using a regex (example done in Java but you can do the same using Groovy regex).

    String id;
    String mailToString; 
    Pattern p = Pattern.compile("Message-ID: <(.*)>");
    Matcher m = p.matcher(mailToString);
    if(m.find()){
        id =  m.group();
    }

@Benoit - it dit not work for me.

instead:

def inbox = store.getFolder('INBOX')
inbox.messages.each{email->
   println "Message-Id: ${email.messageID}"
   }

did the job perfectly.

The same works also for each Part of a Multipart email.

cheers.


Need Your Help

fatal error. launching activity in android

java android android-layout android-intent

I want to access Confirmation activity from login activity. i was able to launch confirmation activity when i didn't have login and registration activity. login and registration works perfect without

Razor if-statement inside jQuery append

jquery razor append

I'm trying to use a razor statement inside a jQuery append.