473,383 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

parsing emails in java

9
I have to parse an email message by separating the "To", "From", "Subject" and body of the text in order to then use this for a spam filter. I am having a difficult time figuring out how to parse the messages any suggestions???
Apr 17 '07 #1
4 3285
sicarie
4,677 Expert Mod 4TB
I have to parse an email message by separating the "To", "From", "Subject" and body of the text in order to then use this for a spam filter. I am having a difficult time figuring out how to parse the messages any suggestions???
What part are you having trouble with? Reading it in, getting a line, getting the message, parsing for a keyword? With the body, are you using grammatical analysis at all, or keywords, something else?
Apr 18 '07 #2
JosAH
11,448 Expert 8TB
I have to parse an email message by separating the "To", "From", "Subject" and body of the text in order to then use this for a spam filter. I am having a difficult time figuring out how to parse the messages any suggestions???
If you really want to dig into how those darn spammers work read RFC 821.

kind regards,

Jos
Apr 18 '07 #3
OCD
9
If you really want to dig into how those darn spammers work read RFC 821.

kind regards,

Jos
I am haviing trouble parsing the body of the message. This is my code. it doesnt give me any errors but when I try to run it and print it to the screen nothing prints HELP!!!!

Expand|Select|Wrap|Line Numbers
  1.  
  2.  boolean messageStarted = false;
  3.            if(line.indexOf("Message Body:") != -1)
  4.             {
  5.                 Scanner scan = new Scanner (line);
  6.                 scan.useDelimiter(Pattern.compile("[<>]"));
  7.                 while(scan.hasNextLine())
  8.                 {
  9.                    if(messageStarted = true)
  10.                    {
  11.                        inBody += line;
  12.                    }
  13.                    if(line.indexOf("Message Body:") != -1)
  14.                    {
  15.                        messageStarted = true;
  16.                    }
  17.                    if(line.indexOf("<END>") != -1)
  18.                    {
  19.                        messageStarted = false;
  20.                        System.out.println(inBody);
  21.                        inBody = "";
  22.                    }
  23.  
  24.  
  25.                 }
  26.  
Apr 20 '07 #4
prometheuzz
197 Expert 100+
I am haviing trouble parsing the body of the message. This is my code. it doesnt give me any errors but when I try to run it and print it to the screen nothing prints HELP!!!!
Looks like you're in an infinite loop since you don't get new lines from your scan object, and thus while(scan.hasNextLine()) will keep looping. Try this:
Expand|Select|Wrap|Line Numbers
  1. while(scan.hasNextLine())
  2. {
  3.   line = scan.nextLine();
  4.  
  5.   // ...
  6.  
  7. }
Apr 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dont bother | last post by:
Hey, I have been trying to parse emails: But I could not find any examples or snippets of parsing emails in python from the documentation. Google did not help me much too. I am trying to...
2
by: Michele Simionato | last post by:
I use Mozilla or Netscape, so my emails are stored in the nsmail directory or the Mozilla's equivalent. What's the simplest way to look at them and extract the mails with a given subject? In...
5
by: sck10 | last post by:
Hello, I am working on a new project where I need to: 1. open an email and then create an xml file from the email 2. open the xml file and parse the information. I would like to be able to do...
0
by: gm04030276 | last post by:
i have to learn java for college and im trying to do a programming assignment at home. in class we use a class file called InOut which simplifys input and output but i can't get the compiler to see...
0
by: hotrod7262 | last post by:
I'm trying to accept UDP multicast XML messages and parse them. The current way I'm doing so is by creating a new File for each message and then calling parser.parse(filename.xml) This way works....
2
by: Terry Olsen | last post by:
I have a very interesting request. A customer receives orders via email. The email contains the shipping address, shipping method, email address and phone number. This information is not all...
4
by: =?Utf-8?B?QWxwYW5h?= | last post by:
I am making a thin email client and want to get emails from a pop3 server...Is there any built in support in C# to get emails from a pop3 server and parse the email to show up on the UI ?
10
dmjpro
by: dmjpro | last post by:
Hi Experts. I have a problem with XML parsing. Please Help! <?xml version="1.0" encoding="UTF-8"?> <XML> <Debasis>some_value</Debasis> <DmjPro>some_another_value</DmjPro> <!--Some...
13
by: Phillip B Oldham | last post by:
Is there a standard library for parsing emails that can cope with the different way email clients quote?
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.