Close
jGuru Forums
Posted By: mohammed_sabir Posted On: Wednesday, February 27, 2002 06:43 AM
I have code which pops mail from my yahoo mail server and now i want to read the mail from the mail server one by one and then store the body of the mail into a file on my local system.could anyone help me out as to how i could do this . sabir ---------- here is the code which first pops the mails from yahoo import javax.mail.*; import javax.mail.internet.*; import java.io.*; import java.util.*; public class ReadMail_JavaMail { public ReadMail_JavaMail() throws MessagingException { } public static void main(String[] a) throws Exception { String POPServer = "pop.mail.yahoo.com"; String UsrLogin = "ssss"; String UsrPass = "ssss"; Properties props = new Properties(); Session session = Session.getDefaultInstance(props, null); session.setDebug(true); Store store = session.getStore("pop3"); store.connect(POPServer,UsrLogin,UsrPass); Folder folder = store.getFolder("INBOX"); System.out.println(folder.getMessageCount()); // getFolder returns -1 because the folder is closed. folder.open(Folder.READ_ONLY); System.out.println(folder.getMessageCount()); Message message[] = folder.getMessages(); for (int x=0, n=message.length; x System.out.println(x + ": " + message[x].getFrom() + " " + message[x].getSubject()); } folder.close(false); store.close(); } } ----- I would like to know the code for storing the body of the message into a file
Re: Javamail
Posted By: John_Zukowski Posted On: Wednesday, February 27, 2002 10:58 AM