List of usage examples for javax.mail BodyPart removeHeader
public void removeHeader(String header_name) throws MessagingException;
From source file:servlets.mailPDF.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/*from www .j av a 2 s .c o m*/ System.out.println("Reached @ mailPDF_Bronze."); String pdfBase64 = request.getParameter("pdfBase64"); String reportdate = request.getParameter("reportdate"); String emailaddresses = request.getParameter("emailList"); String emailMessage = request.getParameter("emailMessage"); String filename = request.getParameter("filename"); List<String> emailList = Arrays.asList(emailaddresses.split("\\s*,\\s*")); System.out.println("pdfBase54 is --------------\n" + pdfBase64 + "\n-----------------End"); System.out.println(reportdate); System.out.println(emailaddresses); byte[] decodedBytes = decode(pdfBase64.substring(28)); MultiPartEmail email = new MultiPartEmail(); email.setSmtpPort(587); email.setDebug(false); email.setHostName("smtp.gmail.com"); email.setAuthentication("reporting@groupnp.com", "D3sign2015"); email.setTLS(true); for (String emailAddress : emailList) { email.addTo(emailAddress); } if (filename.equals("LNIndia Tracker (Gold - Weekly)")) { email.setFrom("reporting@groupnp.com"); email.setSubject(filename + " (" + reportdate + ")"); MimeMultipart part1 = new MimeMultipart(); BodyPart messageBodyPart1 = new MimeBodyPart(); messageBodyPart1.setContent(emailMessage, "text/html; charset=utf-8"); part1.addBodyPart(messageBodyPart1); email.addPart(part1); MimeMultipart part2 = new MimeMultipart(); BodyPart messageBodyPart2 = new MimeBodyPart(); messageBodyPart2 .setDataHandler(new DataHandler(new ByteArrayDataSource(decodedBytes, "application/pdf"))); messageBodyPart2.removeHeader("Content-Transfer-Encoding"); messageBodyPart2.addHeader("Content-Transfer-Encoding", "base64"); messageBodyPart2.setFileName(filename + " " + reportdate + ".pdf"); part2.addBodyPart(messageBodyPart2); email.addPart(part2); email.send(); } else if (filename.equals("LNIndia Tracker (Gold - Monthly)")) { email.setFrom("reporting@groupnp.com"); email.setSubject(filename + " (" + reportdate + ")"); MimeMultipart part1 = new MimeMultipart(); BodyPart messageBodyPart1 = new MimeBodyPart(); messageBodyPart1.setContent(emailMessage, "text/html; charset=utf-8"); part1.addBodyPart(messageBodyPart1); email.addPart(part1); MimeMultipart part2 = new MimeMultipart(); BodyPart messageBodyPart2 = new MimeBodyPart(); messageBodyPart2 .setDataHandler(new DataHandler(new ByteArrayDataSource(decodedBytes, "application/pdf"))); messageBodyPart2.removeHeader("Content-Transfer-Encoding"); messageBodyPart2.addHeader("Content-Transfer-Encoding", "base64"); messageBodyPart2.setFileName(filename + " " + reportdate + ".pdf"); part2.addBodyPart(messageBodyPart2); email.addPart(part2); email.send(); } } catch (EmailException | MessagingException ex) { Logger.getLogger(mailPDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:servlets.mailPDF_Bronze.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {//from ww w. jav a 2 s. c o m System.out.println("Reached @ mailPDF_Bronze."); String pdfBase64 = request.getParameter("pdfBase64"); String reportdate = request.getParameter("reportdate"); String emailaddresses = request.getParameter("emailList"); String emailMessage = request.getParameter("emailMessage"); List<String> emailList = Arrays.asList(emailaddresses.split("\\s*,\\s*")); System.out.println("pdfBase54 is --------------\n" + pdfBase64 + "\n-----------------End"); System.out.println(reportdate); System.out.println(emailaddresses); byte[] decodedBytes = decode(pdfBase64.substring(28)); MultiPartEmail email = new MultiPartEmail(); email.setSmtpPort(587); email.setDebug(false); email.setHostName("smtp.gmail.com"); email.setAuthentication("reporting@groupnp.com", "D3sign2015"); email.setTLS(true); for (String emailAddress : emailList) { email.addTo(emailAddress); } email.setFrom("reporting@groupnp.com"); email.setSubject("LexisNexis Risk India Tracker (" + reportdate + ")"); MimeMultipart part1 = new MimeMultipart(); BodyPart messageBodyPart1 = new MimeBodyPart(); messageBodyPart1.setContent(emailMessage, "text/html; charset=utf-8"); part1.addBodyPart(messageBodyPart1); email.addPart(part1); MimeMultipart part2 = new MimeMultipart(); BodyPart messageBodyPart2 = new MimeBodyPart(); messageBodyPart2 .setDataHandler(new DataHandler(new ByteArrayDataSource(decodedBytes, "application/pdf"))); messageBodyPart2.removeHeader("Content-Transfer-Encoding"); messageBodyPart2.addHeader("Content-Transfer-Encoding", "base64"); messageBodyPart2.setFileName("LNIndiaTracker_" + reportdate + ".pdf"); part2.addBodyPart(messageBodyPart2); email.addPart(part2); email.send(); } catch (EmailException | MessagingException ex) { Logger.getLogger(mailPDF_Bronze.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:servlets.mailPDF_Bronze_ACS.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {// w w w.j av a 2 s . co m System.out.println("Reached @ mailPDF_Bronze."); String pdfBase64 = request.getParameter("pdfBase64"); String reportdate = request.getParameter("reportdate"); String emailaddresses = request.getParameter("emailList"); String emailMessage = request.getParameter("emailMessage"); List<String> emailList = Arrays.asList(emailaddresses.split("\\s*,\\s*")); System.out.println("pdfBase54 is --------------\n" + pdfBase64 + "\n-----------------End"); System.out.println(reportdate); System.out.println(emailaddresses); byte[] decodedBytes = decode(pdfBase64.substring(28)); MultiPartEmail email = new MultiPartEmail(); email.setSmtpPort(587); email.setDebug(false); email.setHostName("smtp.gmail.com"); email.setAuthentication("reporting@groupnp.com", "D3sign2015"); email.setTLS(true); for (String emailAddress : emailList) { email.addTo(emailAddress); } email.setFrom("reporting@groupnp.com"); email.setSubject("ACS Tracker (" + reportdate + ")"); MimeMultipart part1 = new MimeMultipart(); BodyPart messageBodyPart1 = new MimeBodyPart(); messageBodyPart1.setContent(emailMessage, "text/html; charset=utf-8"); part1.addBodyPart(messageBodyPart1); email.addPart(part1); MimeMultipart part2 = new MimeMultipart(); BodyPart messageBodyPart2 = new MimeBodyPart(); messageBodyPart2 .setDataHandler(new DataHandler(new ByteArrayDataSource(decodedBytes, "application/pdf"))); messageBodyPart2.removeHeader("Content-Transfer-Encoding"); messageBodyPart2.addHeader("Content-Transfer-Encoding", "base64"); messageBodyPart2.setFileName("ACSTracker_" + reportdate + ".pdf"); part2.addBodyPart(messageBodyPart2); email.addPart(part2); email.send(); } catch (EmailException | MessagingException ex) { Logger.getLogger(mailPDF_Bronze_ACS.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:servlets.mailPDF_Bronze_Temenos.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {// w w w . j a v a 2 s . co m System.out.println("Reached @ mailPDF_Bronze."); String pdfBase64 = request.getParameter("pdfBase64"); String reportdate = request.getParameter("reportdate"); String emailaddresses = request.getParameter("emailList"); String emailMessage = request.getParameter("emailMessage"); List<String> emailList = Arrays.asList(emailaddresses.split("\\s*,\\s*")); System.out.println("pdfBase54 is --------------\n" + pdfBase64 + "\n-----------------End"); System.out.println(reportdate); System.out.println(emailaddresses); byte[] decodedBytes = decode(pdfBase64.substring(28)); MultiPartEmail email = new MultiPartEmail(); email.setSmtpPort(587); email.setDebug(false); email.setHostName("smtp.gmail.com"); email.setAuthentication("reporting@groupnp.com", "D3sign2015"); email.setTLS(true); for (String emailAddress : emailList) { email.addTo(emailAddress); } email.setFrom("reporting@groupnp.com"); email.setSubject("Temenos Tracker (" + reportdate + ")"); MimeMultipart part1 = new MimeMultipart(); BodyPart messageBodyPart1 = new MimeBodyPart(); messageBodyPart1.setContent(emailMessage, "text/html; charset=utf-8"); part1.addBodyPart(messageBodyPart1); email.addPart(part1); MimeMultipart part2 = new MimeMultipart(); BodyPart messageBodyPart2 = new MimeBodyPart(); messageBodyPart2 .setDataHandler(new DataHandler(new ByteArrayDataSource(decodedBytes, "application/pdf"))); messageBodyPart2.removeHeader("Content-Transfer-Encoding"); messageBodyPart2.addHeader("Content-Transfer-Encoding", "base64"); messageBodyPart2.setFileName("TemenosTracker_" + reportdate + ".pdf"); part2.addBodyPart(messageBodyPart2); email.addPart(part2); email.send(); } catch (EmailException | MessagingException ex) { Logger.getLogger(mailPDF_Bronze_Temenos.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:servlets.mailPDF_Bronze_Yougov.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/*from w ww . ja v a2s . com*/ System.out.println("Reached @ mailPDF_Bronze_Yougov."); String pdfBase64 = request.getParameter("pdfBase64"); String reportdate = request.getParameter("reportdate"); String emailaddresses = request.getParameter("emailList"); String emailMessage = request.getParameter("emailMessage"); List<String> emailList = Arrays.asList(emailaddresses.split("\\s*,\\s*")); System.out.println("pdfBase54 is --------------\n" + pdfBase64 + "\n-----------------End"); System.out.println(reportdate); System.out.println(emailaddresses); byte[] decodedBytes = decode(pdfBase64.substring(28)); MultiPartEmail email = new MultiPartEmail(); email.setSmtpPort(587); email.setDebug(false); email.setHostName("smtp.gmail.com"); email.setAuthentication("reporting@groupnp.com", "D3sign2015"); email.setTLS(true); for (String emailAddress : emailList) { email.addTo(emailAddress); } email.setFrom("reporting@groupnp.com"); email.setSubject("Yougov Tracker (" + reportdate + ")"); MimeMultipart part1 = new MimeMultipart(); BodyPart messageBodyPart1 = new MimeBodyPart(); messageBodyPart1.setContent(emailMessage, "text/html; charset=utf-8"); part1.addBodyPart(messageBodyPart1); email.addPart(part1); MimeMultipart part2 = new MimeMultipart(); BodyPart messageBodyPart2 = new MimeBodyPart(); messageBodyPart2 .setDataHandler(new DataHandler(new ByteArrayDataSource(decodedBytes, "application/pdf"))); messageBodyPart2.removeHeader("Content-Transfer-Encoding"); messageBodyPart2.addHeader("Content-Transfer-Encoding", "base64"); messageBodyPart2.setFileName("YougovTracker_" + reportdate + ".pdf"); part2.addBodyPart(messageBodyPart2); email.addPart(part2); email.send(); } catch (EmailException | MessagingException ex) { Logger.getLogger(mailPDF_Bronze_Yougov.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:servlets.mailPDF_Demo.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/*from ww w.j av a2 s.c om*/ System.out.println("Reached @ mailPDF_Demo."); String pdfBase64 = request.getParameter("pdfBase64"); String reportdate = request.getParameter("reportdate"); String emailaddresses = request.getParameter("emailList"); String emailMessage = request.getParameter("emailMessage"); List<String> emailList = Arrays.asList(emailaddresses.split("\\s*,\\s*")); System.out.println("pdfBase54 is --------------\n" + pdfBase64 + "\n-----------------End"); System.out.println(reportdate); System.out.println(emailaddresses); byte[] decodedBytes = decode(pdfBase64.substring(28)); MultiPartEmail email = new MultiPartEmail(); email.setSmtpPort(587); email.setDebug(false); email.setHostName("smtp.gmail.com"); email.setAuthentication("reporting@groupnp.com", "D3sign2015"); email.setTLS(true); for (String emailAddress : emailList) { email.addTo(emailAddress); } email.setFrom("reporting@groupnp.com"); email.setSubject("Yougov Tracker (" + reportdate + ")"); MimeMultipart part1 = new MimeMultipart(); BodyPart messageBodyPart1 = new MimeBodyPart(); messageBodyPart1.setContent(emailMessage, "text/html; charset=utf-8"); part1.addBodyPart(messageBodyPart1); email.addPart(part1); MimeMultipart part2 = new MimeMultipart(); BodyPart messageBodyPart2 = new MimeBodyPart(); messageBodyPart2 .setDataHandler(new DataHandler(new ByteArrayDataSource(decodedBytes, "application/pdf"))); messageBodyPart2.removeHeader("Content-Transfer-Encoding"); messageBodyPart2.addHeader("Content-Transfer-Encoding", "base64"); messageBodyPart2.setFileName("HCL_DemoTracker_" + reportdate + ".pdf"); part2.addBodyPart(messageBodyPart2); email.addPart(part2); email.send(); } catch (EmailException | MessagingException ex) { Logger.getLogger(mailPDF_Demo.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:servlets.mailPDF_Gold_CitrixChina.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/* w w w . ja v a 2s . c om*/ System.out.println("Reached @ mailPDF_Gold_CitrixChina."); String pdfBase64 = request.getParameter("pdfBase64"); String reportdate = request.getParameter("reportdate"); String emailaddresses = request.getParameter("emailList"); String emailMessage = request.getParameter("emailMessage"); String filename = request.getParameter("filename"); List<String> emailList = Arrays.asList(emailaddresses.split("\\s*,\\s*")); System.out.println("pdfBase64 is --------------\n" + pdfBase64 + "\n-----------------End"); System.out.println(reportdate); System.out.println(emailaddresses); byte[] decodedBytes = decode(pdfBase64.substring(28)); MultiPartEmail email = new MultiPartEmail(); email.setSmtpPort(587); email.setDebug(false); email.setHostName("smtp.gmail.com"); email.setAuthentication("reporting@groupnp.com", "D3sign2015"); email.setTLS(true); for (String emailAddress : emailList) { email.addTo(emailAddress); } email.setFrom("reporting@groupnp.com"); email.setSubject(filename + " (" + reportdate + ")"); MimeMultipart part1 = new MimeMultipart(); BodyPart messageBodyPart1 = new MimeBodyPart(); messageBodyPart1.setContent(emailMessage, "text/html; charset=utf-8"); part1.addBodyPart(messageBodyPart1); email.addPart(part1); MimeMultipart part2 = new MimeMultipart(); BodyPart messageBodyPart2 = new MimeBodyPart(); messageBodyPart2 .setDataHandler(new DataHandler(new ByteArrayDataSource(decodedBytes, "application/pdf"))); messageBodyPart2.removeHeader("Content-Transfer-Encoding"); messageBodyPart2.addHeader("Content-Transfer-Encoding", "base64"); messageBodyPart2.setFileName(filename + " " + reportdate + ".pdf"); part2.addBodyPart(messageBodyPart2); email.addPart(part2); email.send(); } catch (EmailException | MessagingException ex) { Logger.getLogger(mailPDF_Gold_CitrixChina.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:servlets.mailPDF_Gold_LexisNexis.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/* www.j a v a 2 s. c om*/ System.out.println("Reached @ mailPDF_Gold_LexisNexis."); String pdfBase64 = request.getParameter("pdfBase64"); String reportdate = request.getParameter("reportdate"); String emailaddresses = request.getParameter("emailList"); String emailMessage = request.getParameter("emailMessage"); String filename = request.getParameter("filename"); List<String> emailList = Arrays.asList(emailaddresses.split("\\s*,\\s*")); System.out.println("pdfBase64 is --------------\n" + pdfBase64 + "\n-----------------End"); System.out.println(reportdate); System.out.println(emailaddresses); byte[] decodedBytes = decode(pdfBase64.substring(28)); MultiPartEmail email = new MultiPartEmail(); email.setSmtpPort(587); email.setDebug(false); email.setHostName("smtp.gmail.com"); email.setAuthentication("reporting@groupnp.com", "D3sign2015"); email.setTLS(true); for (String emailAddress : emailList) { email.addTo(emailAddress); } email.setFrom("reporting@groupnp.com"); email.setSubject(filename + " (" + reportdate + ")"); MimeMultipart part1 = new MimeMultipart(); BodyPart messageBodyPart1 = new MimeBodyPart(); messageBodyPart1.setContent(emailMessage, "text/html; charset=utf-8"); part1.addBodyPart(messageBodyPart1); email.addPart(part1); MimeMultipart part2 = new MimeMultipart(); BodyPart messageBodyPart2 = new MimeBodyPart(); messageBodyPart2 .setDataHandler(new DataHandler(new ByteArrayDataSource(decodedBytes, "application/pdf"))); messageBodyPart2.removeHeader("Content-Transfer-Encoding"); messageBodyPart2.addHeader("Content-Transfer-Encoding", "base64"); messageBodyPart2.setFileName(filename + " " + reportdate + ".pdf"); part2.addBodyPart(messageBodyPart2); email.addPart(part2); email.send(); } catch (EmailException | MessagingException ex) { Logger.getLogger(mailPDF_Gold_LexisNexis.class.getName()).log(Level.SEVERE, null, ex); } }