aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes java mail api Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "java mail api " Watch "java mail api " New topic
Author

java mail api

pallavi agrawal
Greenhorn

Joined: Mar 29, 2004
Posts: 1
hi,
i m trying to implement a mail client using java mail api. but i m not able to connect my client to the server.n not able to create a session and authenticate user id n password. how should i proceed?
eammon bannon
Ranch Hand

Joined: Mar 16, 2004
Posts: 140
Can we see your error?
Sergiu Truta
Ranch Hand

Joined: Dec 16, 2003
Posts: 121
This is an example for FETCHING messages:
String host = ...;
String username = ...;
String password = ...;
// Create empty properties
Properties props = new Properties();
// Get session
Session session = Session.getDefaultInstance(props, null);
// Get the store
Store store = session.getStore("pop3");
store.connect(host, username, password);
// Get folder
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
// Get directory
Message message[] = folder.getMessages();
for (int i=0, n=message.length; i<n; i++) {
System.out.println(i + ": " + message[i].getFrom()[0]
+ "\t" + message[i].getSubject());
}
// Close connection
folder.close(false);
store.close();

For more info you might want to check this out.


...watch me...as I'm walking the path...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java mail api
 
Similar Threads
Reading HTML mail and Images using Java Mail API
Please Help its urgent
retrieving body of a mail message
How to hide FROM attribute in mail
How can i send mail to different user on different smtp servers.