Zdravim.
Mam na disku nekolik tisic emailu,ktere bych chtel zpracovat.Jsou ve tvaru:
Message-ID: <4046719.1075855815569.JavaMail.evans@thyme>
Date: Thu, 2 Mar 2000 22:55:00 -0800 (PST)
From:bob.klein@enron.com
To:brenda.herod@enron.com
Subject: Re: Interim Operational, Accounting and Tax Services porvided by ENA
Cc:curry@texaco.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Bcc:curry@texaco.com
X-From: Bob Klein
X-To: Brenda F Herod
X-cc:
X-bcc:
X-Origin: Beck-S
X-FileName: sbeck.nsf
I agree with the section written for settlements. I would very much like to
be included in your meeting.
Thanks,
Bob
Enron North America Corp.
The attached document is draft 4 of the Interim services ENA will provide to
Bridgeline. Please review and provide any comments ASAP as we are working
towards a FINAL version.
I will be coordinating a meeting for next week to review these services and
provide a status. If you are interested in attending, please let me know.
Thanks,
Brenda
713-853-5778
A chtel bych z nich ziskat predmet, a telo prispevku.
Pokousel jsem se o to takhle:
import java.io.*;
import java.util.*;
import javax.mail.*;
public class cti {
public static void main(String [] args) throws Exception {
String dir = "emaily";
try {
File Dir = new File(dir);
File[] DirList = Dir.listFiles();
for (int i = 0; i < DirList.length; i++) {
BufferedReader bfr = new BufferedReader (new FileReader(DirList[i]));
Mail m = new Mail(new FileInputStream(DirList[i]));
System.out.println("SUUBJECT:" + m.getSubject() );
bfr.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
ale bohuzel v radku:
Mail m = new Mail(new FileInputStream(DirList[i]));
podrthle Eclipse cervene obe slova Mail a hlasi tuto chybu:
Multiple markers at this line
-Mail cannot be resolved to a type
-Mail cannot be resilved to a type
Nevedel by nekdo co delam spatne,nebo jak na to? Diky za napady a rady
Fórum › Java
Java - čení emailů na disku

AFAIK java.mail zadny parser neobsahuje, takze si budes muset ten textak rozparsovat sam. V tomto smeru je ti import javax.mail uplne k nicemu.
Udelej si vlastni tridu Mail a metodu parse(InputStream in) a tam si naimplementuj vlastni parsovani mailu. Pokud potrebujes jenom predmet a telo tak to mas jednoduche. Staci vzit radku ktera zacina Subject: a pak prazdny radek symbolizuje zacatek tela zpravy.
To paja : Jo tak to by bylo dosti kontraproduktivni. Regularni vyrazy na to urcite nepotrebujes. Dokonce by to bylo dost plitvani v takto jednoduchem pripade.
To jboss : A jak na to tedy? Diky za napady a rady. Uz jsem z toho fakt na prasky
To asi budete jeste chvilku. No bud pouzijete regularni vyrazy. Protoze sice nejsou efektivni (pro tuto ulohu), ale zase jsou dobre zdokumentovany.
A nebo proste nactete soubor do buffered readeru a nechate si vracet jednotlive radky mailu. (metoda readLine) a v nich pres indexOf budete hledat subject.
Stejne tak dokazete zjistit, ze je konec hlavicky a zacina vlastni email.
Je to na par radek.
metoda IndexOf http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
a tady priklad cteni souboru pres readLine
http://www.cafeaulait.org/slides/sd2000west/javaio/54.html

Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
































Uživatelé prohlížející si toto vlákno
Podobná vlákna
Java čtení emailů přes pop3 — založil Ondra
Posielanie emailu — založil bugisoft
Diakritika v emailu — založil Adam
Posílání emailů ?? — založil wokena
Zaslání emailu v C++ — založil Milanz
Moderátoři diskuze