File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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