Thursday, 7 May 2015

POP3 PROGRAM IN JAVA

      import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;

public class POP3Client
{
public static void main(String args[])
{
Properties props=new Properties();
String host=”gmail.com”;
String username=”user”;
String password=”pass”;
String provider=”POP3”;
try
{
Session session=session.getDefaultInstance(props,null);
Store store=session.getStore(provider);
store.connect(host,username,password);
Folder inbox=store.getFolder(“INBOX”);
inbox.open(Folder.READ_ONLY);
Message[]messages=inbox.getMessages();
for(int  i=0;i<messages.length;i++)
{
System.out.println(“……Message”+(i+1)+”………”);
messages[i].writeTo(System.out);
}
inbox.close(False);
store.close();
}
}
}

No comments:

Post a Comment