Popping messages using JAVA MAIL API
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Satish_Tiruman
Posted On:   Sunday, November 11, 2001 06:45 PM

Hi, I am using a program to get messages from my mail server using Java Mail API. That file is compiling properly. But when i am executing it is giving the following error : java.lang.NoClassDefFoundError: javax/mail/Session at GetMessageExample.main(Compiled Code) Can anyone answer my question? Thanks in advance This is The code i am using : import java.io.*; import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; public class GetMessageExample { public static void main (String args[]) throws Exception { String host = args[   More>>


Hi,


I am using a program to get messages from my mail server using Java Mail API.
That file is compiling properly. But when i am executing it is giving the following error :


java.lang.NoClassDefFoundError: javax/mail/Session at GetMessageExample.main(Compiled Code)


Can anyone answer my question? Thanks in advance


This is The code i am using :


import java.io.*;


import java.util.Properties;


import javax.mail.*;


import javax.mail.internet.*;



public class GetMessageExample {
public static void main (String args[]) throws Exception {


String host = args[0];


String username = args[1];


String password = args[2];


// Create empty properties

Properties props = new Properties();


// Get session


Session session =
Session.getDefaultInstance(props, null);


// Get the store
//Store store = session.getStore("imap");


Store store = session.getStore("pop3");


// Connect to store

store.connect(host, username, password);


// Get folder

Folder folder = store.getFolder("INBOX");


// Open read-only

folder.open(Folder.READ_ONLY);


BufferedReader reader = new BufferedReader (
new InputStreamReader(System.in));


// Get directory

Message message[] = folder.getMessages();


for (int i=0, n=message.length; i


// Display from field and subject

System.out.println(i + ": " + message[i].getFrom()[0]
+ " " + message[i].getSubject());


System.out.println("Do you want to read message? [YES to read/QUIT to end]");

String line = reader.readLine();

if ("YES".equals(line)) {


// Display message content

System.out.println(message[i].getContent());


} else if ("QUIT".equals(line)) {

break;
}
}


// Close connection

folder.close(false);
store.close();
}
}

   <<Less

Re: Popping messages using JAVA MAIL API

Posted By:   John_Zukowski  
Posted On:   Monday, November 12, 2001 04:55 PM

If I had to guess, I would say your runtime CLASSPATH is different then your compile-time CLASSPATH. make sure the JavaMail classes are present in your runtime environment.
About | Sitemap | Contact