public void sendSSL(String to, String from1, String host1, String port1, String subject, String body, String fileAttachment1, String attachmentMimeType1, String username1, String password1) throws Exception { String username = username1; String password = password1; String from = from1; String host = host1; String smtpPort = port1; String attachmentMimeType = attachmentMimeType1; String fileAttachment = fileAttachment1; String[] tosendadd = new String[1]; from = username; tosendadd[0] = to; Properties props = new Properties(); props.put("mail.pop3.host", host); Session session = Session.getDefaultInstance(props); props.put("mail.smtp.user", username); props.put("mail.smtp.password", password); props.put("mail.smtp.host", host); props.put("mail.smtp.port", smtpPort); int toCount = tosendadd.length; session = Session.getDefaultInstance(props, null); System.out.println("check"); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); InternetAddress[] address = new InternetAddress[toCount]; for (int i = 0; i < toCount; i++) address[i] = new InternetAddress(tosendadd[i]); message.setRecipients(Message.RecipientType.TO, address); message.setSubject(subject); MimeBodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setDataHandler(new DataHandler(new HTMLDataSource(body))); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); System.out.println("dhirendra1"); if (fileAttachment != null) { messageBodyPart = new MimeBodyPart(); FileDataSource fds = new FileDataSource(fileAttachment); messageBodyPart.setDataHandler(new DataHandler(fds)); messageBodyPart.setFileName("abc.zip"); multipart.addBodyPart(messageBodyPart); } System.out.println("dhirendra2"); message.setContent(multipart); Transport.send(message); System.out.println("dhirendra3"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)