It have been long since I asked for help on the forums but latly I have been Struggling with this problem for a couple of days.
read all the forums did all ppl did but no change.
What the H I am doing wrong ?
by the way I am using javamail 5.1 and java 8 and already send text msg so no problem with properties
here is my code
// Get system properties Properties properties = System.getProperties(); // Setup mail server properties.put("mail.smtp.starttls.enable", "true"); properties.put("mail.smtp.host", mailHost); properties.put("mail.smtp.user", mailUserName); properties.put("mail.smtp.password", mailPassword); properties.put("mail.smtp.port", "587"); properties.put("mail.smtp.auth", "true"); // Get the default Session object. Session session = Session.getDefaultInstance(properties); try{ // Create a default MimeMessage object. MimeMessage message = new MimeMessage(session); // Set From: header field of the header. message.setFrom(new InternetAddress(mD.mailUserName)); // Set To: header field of the header. message.addRecipient(Message.RecipientType.TO,new InternetAddress(to)); Multipart multiPart = new MimeMultipart(); MimeBodyPart textPart = new MimeBodyPart(); textPart.setText("This is actual message", "text/html; charset=utf-8"); MimeBodyPart htmlPart = new MimeBodyPart(); htmlPart.setContent(html, "text/html; charset=utf-8"); multiPart.addBodyPart(textPart); multiPart.addBodyPart(htmlPart); message.setContent(multiPart); // Send message Transport transport = session.getTransport("smtp"); transport.connect( mD.mailHost,mD.mailUserName,mD.mailPassword); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( javax.mail.Session.class.getClassLoader() ); try { message.setContent(multiPart); //transport.sendMessage(message, message.getAllRecipients()); Transport.send(message, message.getAllRecipients()); } catch (MessagingException e) { e.printStackTrace(); } finally { Thread.currentThread().setContextClassLoader(classLoader); } transport.close(); } catch (MessagingException mex) { mex.printStackTrace(); }