Guest User

Untitled

a guest
Dec 31st, 2018
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. // Create the attachment
  2. EmailAttachment attachment = new EmailAttachment();
  3. attachment.setPath(".\Test-Report.html");
  4. attachment.setDisposition(EmailAttachment.ATTACHMENT);
  5. attachment.setDescription("ePQS AT Report");
  6. attachment.setName("ePQS AT Report");
  7.  
  8. // Create the email message
  9. MultiPartEmail email = new MultiPartEmail();
  10. email.setHostName("smtp.gmail.com");
  11. email.setAuthenticator(new DefaultAuthenticator("peterapiit@gmail.com", "giqqpudmcjjmpbcc"));
  12. email.addTo("peterapiit@gmail.com", "Nicholas Wong");
  13. email.setFrom("peterapiit@gmail.com", "Nicholas Wong");
  14. email.setSubject("Test Email");
  15. email.setMsg("Here is the picture you wanted");
  16. email.setStartTLSEnabled(true);
  17. email.setDebug(true);
  18. email.setSmtpPort(587);
  19.  
  20. // add the attachment
  21. email.attach(attachment);
  22.  
  23. // send the email
  24. email.send();
Add Comment
Please, Sign In to add comment