2010-01-23 7 views

답변

0

그냥 sinetfactory의 html 폴더에있는 문서를 사용하십시오. 모든 것이 있습니다.

import com.jscape.inet.imap.*; 
import com.jscape.inet.email.*; 
import com.jscape.inet.imapssl.ImapSsl; 
import com.jscape.inet.mime.*; 
import java.io.*; 

public class ImapSshExample { 
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));; 

    public void getMessages() throws ImapException, MimeException, IOException { 

     ImapSsl imap = new ImapSsl("imap.gmail.com", 993, "username", "password"); 
     imap.connect(); 
     int messageCount = imap.getMessageCount(); 

     for (int i = 1; i <= messageCount; i++) { 
      EmailMessage msg = imap.getMessage(i); 
      System.out.println("-- begin message --"); 
      System.out.println(new String(msg.getMessage())); 
      System.out.println("-- end message --"); 

      System.out.print("ENTER for next message or type QUIT to quit: "); 
      String command = reader.readLine(); 
      if (command.equalsIgnoreCase("quit")) { 
       break; 
      } 
     } 
     imap.disconnect(); 
    } 

    public static void main(String[] args) { 
     try { 
      ImapSshExample example = new ImapSshExample(); 
      example.getMessages(); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 
} 
+0

을하지만, 내가 어떻게 새로운 또는 읽지있는 이메일에 액세스 할 수 있습니다. –

0

헤이는 문서에 보면 : 이것은 당신이 새 메시지를 얻을 수있는 방법입니다 :

// get messages in mailbox 
Enumeration e = imap.getNewMessages(); 

// loop thru all messages in mailbox 
while(e.hasMoreElements()) { 
EmailMessage message = (EmailMessage)e.nextElement(); 
// print out subject, or do what you want 
System.out.println(message.getSubject()); 
관련 문제