import java.awt.*; import javax.swing.*; import java.io.*; import java.util.*; import javax.mail.*; public class TextAreaDemoB extends JFrame { JTextArea _resultArea = new JTextArea(6, 35); public TextAreaDemoB() throws Exception { String host = "pop.gmail.com"; String user = "computingcloud14@gmail.com"; String password = "QWERTYASDFG"; Properties properties = System.getProperties(); Session session = Session.getDefaultInstance(properties, null); Store store = session.getStore("pop3s"); store.connect(host, user, password); Folder folder = store.getFolder("inbox"); folder.open(Folder.READ_ONLY); Message[] message = folder.getMessages(); for (int i = 0; i < message.length; i++) { String myString = Integer.toString(i); _resultArea.append(myString); _resultArea.append("------------ Message " + (i + 1) + " ------------"); _resultArea.append("SentDate : " + message[i].getSentDate()); _resultArea.append("From : " + message[i].getFrom()[0]); _resultArea.append("Subject : " + message[i].getSubject()); InputStream stream = message[i].getInputStream(); //The following loop must be changed to achieve my solution.can any1??????? do { //_resultArea.setText((); char d=(char) stream.read(); String c=Character.toString(d); //_resultArea.append(c); System.out.println(c); } while (stream.available() != 0); } JScrollPane scrollingArea = new JScrollPane(_resultArea); JPanel content = new JPanel(); content.setLayout(new BorderLayout()); content.add(scrollingArea, BorderLayout.CENTER); this.setContentPane(content); this.setTitle("TReadMails"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.pack(); } //============================================================= main public static void main(String[] args) throws Exception { JFrame win = new TextAreaDemoB(); win.setVisible(true); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)