dcsimg
Downloading messages as an Array using:!_NEWLINE_!Message[] messages = folder.getMessages();
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Arthur_Embleton
Posted On:   Sunday, September 8, 2002 01:50 PM

I have been experimenting with the JavaMail API and have come across a problem. I have successfully connected to a POP server and retrieved the number of messages that are stored in a folder. I'm trying to download the messages by using the getMessages() function. According to the documentation this returns an array of type Message so I have created an array of type Message to copy them into as show below: Code: Message[] messages = folder.getMessages(); folder is an instance of a class called Folder that contains the contents of my inbox. The code I used for that is: Code:    More>>

I have been experimenting with the JavaMail API and have come across a problem.





I have successfully connected to a POP server and retrieved the number of messages that are stored in a folder. I'm trying to download the messages by using the getMessages() function. According to the documentation this returns an array of type Message so I have created an array of type Message to copy them into as show below:


Code:
Message[] messages = folder.getMessages();




folder is an instance of a class called Folder that contains the contents of my inbox. The code I used for that is:
Code:
Folder folder = store.getDefaultFolder();


folder = folder.getFolder("INBOX");



store is an instance of a class called Store that actually connects me to my POP mailbox. The code for that is:
Code:
Store store = session.getStore("pop3");



store.connect (pop3Host, -1, user, password);


pop3Host is a string that is set earlier on as pop.mail.yahoo.com


user is a string that is set as amembleton


password is a string that contains my password!





Everything except for the
Code:
Message[] messages = folder.getMessages();
definetelly works as I used it to get the number of messages in my Inbox. It compiles fine but when I execute the code I get the following error:






Exception in thread "main" java.lang.NoClassDefFoundError:


javax/activation/DataSource


at com.sun.mail.pop3.POP3Folder.createMessage(POP3Folder.java:284)


at com.sun.mail.pop3.POP3Folder.getMessage(POP3Folder.java:265)


at javax.mail.Folder.getMessages(Folder.java:903)


at msgcount.process(msgcount.java:44)






Line 44 is:
Code:
Message[] messages = folder.getMessages();






I don't know why this is having such a problem. I've also tried it with webtribe.net incase it was yahoo that was causing the trouble but that didn't work either.





If anyone has any suggestions, please reply.





Thanks in advance, Arthur    <<Less

Re: Downloading messages as an Array using:!_NEWLINE_!Message[] messages = folder.getMessages();

Posted By:   Erik_Duijs  
Posted On:   Wednesday, October 2, 2002 04:17 AM

It seems to me you don't have activation.jar in your classpath.

Good luck,
Erik
About | Sitemap | Contact