parse emails


EJB design: parse emails

  1. parse emails (4 messages)

    I am designing a system that will have to parse emails at some point. For example a member receives a plain text email from the web site. The reply contains a yes or no in the first line and a string in the title. The system recognizes who sent the email, reads the title and the first line, and then does x depending on the reply what is contained in the email.

    Can anyone tell me a good source of info regarding how to do this in Java. Can an ejb handle an email directly or would the email be sent to pop box somewhere and then regularly polled by my application?

    I am assuming this is similar to how mailing lists subscribe and unsubscribe members.



    Threaded Messages (4)

  2. A bit confused...[ Go to top ]

    Who sends the email? The web site, or the user? You said...

    "...For example a member receives a plain text email from the web site..."

    I think what you meant to say was that the user sends the email to the web site and not the other way around, otherwise, if the user receives the email, there is not much they can do other than reading it.

    Does the system require that you use email as the communication means for transfering the message? If not, then I would recommend using JMS instead.

  3. more clearly[ Go to top ]

    Our web application sends an email to a user. The user then replies to the email. In the reply message there is a "yes" or "no". The web application processes the email, it does x if yes or y if no. The use of email is required.

    How do I best process the reply?

  4. No prob![ Go to top ]

    You can use the JavaMail API to read email messages from a mail server. Refer to the JavaMail API and Tutorial at the SUN site for more information, but your code for accessing the subject and body parts of the messages in the Inbox would look something like this (of course, you need to configure your code to access the specific folder)

    Folder root = mailStore.getDefaultFolder();
    Folder inbox = root.getFolder("INBOX");;

    Message[] allMesgs = inbox.getMessages();
    for( int i = 0; i < allMesgs.length; i++){
      System.out.println( allMesgs[i].subject());

    Hope it helps!

  5. Thanks[ Go to top ]

    ... will read the tutorials.