This discussion is archived
7 Replies Latest reply: Oct 29, 2012 8:42 AM by 803208 RSS

nullpointer exception in IMAPFOLDER class when run under 64 bit os

970707 Newbie
Currently Being Moderated
Hi all,
I am getting a strange error.I have a class which send email and saves it in gmail drafts.When i run the same code with 32 bit os it works perfectly and attaches the file with email saving in gmail drats.When i do the same with 64 bit os it doesnt send the mail (with attachment).If i remove the attachment part it works fineeven on 64 bit machine and sends the mail.Here is the exception
java.lang.NullPointerException
at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:226)
at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:299)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1375)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1021)
at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:419)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1354)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2107)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2075)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1770)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1749)
at com.sun.mail.imap.MessageLiteral.<init>(IMAPFolder.java:2835)
at com.sun.mail.imap.IMAPFolder.appendUIDMessages(IMAPFolder.java:1472)
at com.sun.mail.imap.IMAPFolder.addMessages(IMAPFolder.java:1517)
at com.java.jagjit.EmailDraft.main(EmailDraft.java:114)

//code to send email
folder = (IMAPFolder) store.getFolder("[Gmail]/Drafts");
if(!folder.isOpen())
folder.open(Folder.READ_WRITE);
//for(int i=0;i<5;i++){
//Message messages = new Message(session);
MimeMessage mimeMsg=new MimeMessage(session);
mimeMsg.setSubject("anderson");
mimeMsg.setSentDate(new Date());
mimeMsg.setText("email text goes here---");
mimeMsg.setFlag(Flag.DRAFT, true);
mimeMsg.setSentDate(new Date());
Multipart mp=new MimeMultipart();
MimeBodyPart mbp=new MimeBodyPart();
mbp.setText("email here-");
mp.addBodyPart(mbp);

FileDataSource fds=new FileDataSource("C:\\Users\\Jagjit\\Desktop\\jagjit.txt");
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);

mimeMsg.setContent(mp);
MimeMessage[] mm={mimeMsg};
/below line shows exception
folder.addMessages(mm);


Please help me if anybody have any idea on this.Thanks in advance

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points