public void sendSSLMessage() throws MessagingException { session.setDebug(true); mailContainer = new MimeMessage( session ); mailText.setText(MAIL_CONTENT); mailMultipart = new MimeMultipart(); mailMultipart.addBodyPart(mailText); FileDataSource fds = new FileDataSource("C:\\Documents and Settings\\tore-\\Desktop\\bøker.doc"); //when next line i executed, i get Exception in thread "main" java.lang.NullPointerException at nith.X.mail.MailSender2.sendSSLMessage(MailSender2.java:185) mailAttachment.setDataHandler(new DataHandler(fds)); mailAttachment.setFileName(fds.getName()); mailMultipart.addBodyPart(mailAttachment); mailContainer.setContent( mailMultipart ); mailContainer.setFrom(SMTP_REPLYTO_ADDRESS); InternetAddress addressTo = new InternetAddress("tore.lonoy@gmail.com"); mailContainer.setRecipient(Message.RecipientType.TO, addressTo);// Setting the Subject and Content Type Transport.send(mailContainer); }