dcsimg
Receiving Mails...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   hari_krishna
Posted On:   Friday, June 1, 2001 05:35 AM

The version of javamail i am using is 1.1.3 and jdk1.2.2 and operating system is windows 2000 On executing the program **************************************** import javax.mail.*; import javax.mail.internet.*; import javax.mail.event.*; public class InBox { String protocol; String host; String user; String password; String mbox; Message[] msgs; Folder folder; Store store; InBox(String user, String pass, String popServer){ protocol = "pop3"; this.user = user; password = pass; host = popServer; mbox = "INBOX"; } public void openFolder()throws NoSuch   More>>

The version of javamail i am using is 1.1.3 and jdk1.2.2 and operating system is windows 2000

On executing the program


****************************************
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.event.*;
public class InBox {
String protocol;
String host;
String user;
String password;
String mbox;
Message[] msgs;
Folder folder;
Store store;

InBox(String user, String pass, String popServer){
protocol = "pop3";
this.user = user;
password = pass;
host = popServer;
mbox = "INBOX";
}

public void openFolder()throws NoSuchProviderException, MessagingException{
java.util.Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props, null);
store = session.getStore(protocol);
store.connect(host,user,password);
folder = store.getDefaultFolder();
if (folder == null) {
System.out.println("No default folder");
System.exit(1);
}
folder = folder.getFolder(mbox);
if (folder == null)
System.out.println("********Folder is null***********");
folder.open(Folder.READ_WRITE);
msgs = folder.getMessages();
}

public void getInbox()throws AuthenticationFailedException, MessagingException{
try{
Address[] add;
String sub;
String from;
for(int j = 0; j < msgs.length; j++) {
if(( add = msgs[j].getFrom()) != null)
for(int k = 0; k < add.length; k++){
from = add[k].toString();
if(from == null)
System.out.println("From Address Unknown");
else System.out.println("From Address " + from);
}
sub = msgs[j].getSubject();
if(sub == null)
System.out.println("Subject Unknown");
else System.out.println("Subject " + sub);
System.out.println("********** " + j+ " **********");
String message = getMessage(j);
System.out.println("Message


" + message);
}
} catch(AuthenticationFailedException afe){
throw new AuthenticationFailedException();
} catch(MessagingException me){
throw new MessagingException();
} catch(Exception e){ }
folder.close(true);
store.close();
}

public String getMessage(int i) throws MessagingException{
Object obj = null;
String msg = "";
try{
msg = msg + getBodyPart(msgs[i]);
}catch(java.io.IOException e){ }
catch(MessagingException me){
throw new MessagingException();
} return msg; }

public String getBodyPart(Part p) throws java.io.IOException, MessagingException {
Object obj = p.getContent();
String str = "";
if(obj instanceof String){
str = str + (String)obj;
} else if(obj instanceof Multipart){
Multipart mp = (Multipart)obj;
int count = mp.getCount();
for(int i =0; i < count; i++){
str = str + getBodyPart(mp.getBodyPart(i));
}
} else if (obj instanceof java.io.InputStream) {
/* InputStream is = (InputStream)obj;
int c; while((c = is.read()) != -1)
System.out.write(c);*/
}
return str;
}

public static void main(String args[]){
InBox inbox = new InBox("uday", "uday", "202.56.199.2");
try{
inbox.openFolder();
inbox.getInbox();
}catch(NoSuchProviderException nospe){
System.out.println("NoSuchProviderException
");
nospe.printStackTrace();
}catch(AuthenticationFailedException mesg){
System.out.println("AuthenticationFailedException
");
mesg.printStackTrace();
}catch(MessagingException afe){
System.out.println("MessagingException
");
afe.printStackTrace();
}
}
}
****************************************


Iam getting the following error:

java.lang.NoSuchFieldError: javax.mail.internet.MimeMessage: field contentStream not found ****************************************


Please help me out in overcoming this error...

   <<Less

Re: Receiving Mails...

Posted By:   John_Zukowski  
Posted On:   Friday, June 1, 2001 01:32 PM

contentStream is a JavaMail 1.2 field.
About | Sitemap | Contact