Examples of EmailAttachment


Examples of com.kentcdodds.javahelper.model.EmailAttachment

   * @throws Exception
   */
  public static EmailAttachment zipAttachments(String attachmentName, EmailAttachment... attachments) throws FileNotFoundException, IOException, Exception {
    HelperFile[] files = new HelperFile[attachments.length];
    for (int i = 0; i < attachments.length; i++) {
      EmailAttachment emailAttachment = attachments[i];
      byte[] fileBytes = emailAttachment.getFileBytes();
      if (fileBytes == null) {
        fileBytes = IOHelper.getFileBytes(emailAttachment.getFile()); //in the case that this is a file on disk
      }
      files[i] = new HelperFile(fileBytes, emailAttachment.getAttachmentName());
    }
    byte[] zippedBytes = IOHelper.zipFiles(files);
    return new EmailAttachment(zippedBytes, "attachments.zip", "application/zip", Message.ATTACHMENT);
  }
View Full Code Here

Examples of org.apache.commons.mail.EmailAttachment

        commonsEmail.setSmtpPort(NumberTools.toInt(email.getPort(), 25));
      }

      if (email.getAttachmentFileName() != null)
      {
        EmailAttachment attachment = new EmailAttachment();

        attachment.setPath(email.getAttachmentFileName());
        attachment.setDisposition(EmailAttachment.ATTACHMENT);
        attachment.setDescription(email.getAttachmentDescription());
        attachment.setName(email.getAttachmentName());
        commonsEmail = ((MultiPartEmail) commonsEmail).attach(attachment);
      }

      commonsEmail.send();
    }
View Full Code Here

Examples of org.apache.commons.mail.EmailAttachment

    public void communicate(IReport report) throws EmailException,
            MoDiException {

        // Create the attachment
        EmailAttachment attachment = new EmailAttachment();
        attachment
                .setPath(Config.getStringProperty("MoDi.HTMLReportFile.Path"));
        attachment.setDisposition(EmailAttachment.ATTACHMENT);
        attachment.setDescription("MoDiHTMLReport");
        attachment.setName("modireport.html");

        // Create the email message
        MultiPartEmail email = new MultiPartEmail();
        email.setHostName(mailhost);
        email.setAuthentication(username, password);
View Full Code Here

Examples of org.apache.commons.mail.EmailAttachment

    public void communicate(IReport report) throws EmailException,
            MoDiException {

        // Create the attachment
        EmailAttachment attachment = new EmailAttachment();
        attachment
                .setPath(Config.getStringProperty("MoDi.HTMLReportFile.Path"));
        attachment.setDisposition(EmailAttachment.ATTACHMENT);
        attachment.setDescription("MoDiHTMLReport");
        attachment.setName("modireport.html");

        // Create the email message
        MultiPartEmail email = new MultiPartEmail();
        email.setHostName(mailhost);
        email.setAuthentication(username, password);
View Full Code Here

Examples of org.apache.commons.mail.EmailAttachment

    public static void mail5() throws EmailException {
        HtmlEmail email = new HtmlEmail();
        email.setHtmlMsg("<html><body><h1>A Title</h1></body></html>");
        email.setTextMsg("alternative message");
        EmailAttachment attachment = new EmailAttachment();
        attachment.setDescription("An image");
        attachment.setDisposition(EmailAttachment.ATTACHMENT);
        attachment.setPath(Play.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond2.png");
        EmailAttachment attachment2 = new EmailAttachment();
        attachment2.setName("fond3.jpg");
        attachment2.setPath(Play.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond3.jpg");
        email.attach(attachment);
        email.attach(attachment2);
        email.setFrom("test@localhost");
        email.addTo("test@localhost");
        email.setSubject("test attachments");
View Full Code Here

Examples of org.apache.commons.mail.EmailAttachment

    public static void mail5() throws EmailException {
        HtmlEmail email = new HtmlEmail();
        email.setHtmlMsg("<html><body><h1>A Title</h1></body></html>");
        email.setTextMsg("alternative message");
        EmailAttachment attachment = new EmailAttachment();
        attachment.setDescription("An image");
        attachment.setDisposition(EmailAttachment.ATTACHMENT);
        attachment.setPath(Play.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond2.png");
        EmailAttachment attachment2 = new EmailAttachment();
        attachment2.setName("fond3.jpg");
        attachment2.setPath(Play.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond3.jpg");
        email.attach(attachment);
        email.attach(attachment2);
        email.setFrom("test@localhost");
        email.addTo("test@localhost");
        email.setSubject("test attachments");
View Full Code Here

Examples of org.apache.commons.mail.EmailAttachment

                    String type = mapping.get("type").toString();
                       
                    try {
                       
                        if ("system".equals(type)) {
                            EmailAttachment attachment = new EmailAttachment();
                            attachment.setPath(path);
                            attachment.setName(MimeUtility.encodeText(fileName));
                            email.attach(attachment);
                        } else {
                            URL u = new URL(path);
                            email.attach(u, MimeUtility.encodeText(fileName), "");
                        }
View Full Code Here

Examples of org.apache.commons.mail.EmailAttachment

  public boolean email(String subject, String body, String toEmail, String fileAttachment, boolean deObf) throws EmailException
  {
    try
    {
      // Create the attachment
      EmailAttachment attachment = new EmailAttachment();
      attachment.setPath(fileAttachment);
      attachment.setDisposition(EmailAttachment.ATTACHMENT);
     
      // Create the email message
      MultiPartEmail email = new MultiPartEmail();
      email.setHostName(this.smtpHostname);
      if ("smtps".equals(this.smtpProtocol))
View Full Code Here

Examples of org.apache.commons.mail.EmailAttachment

    public static void mail5() throws EmailException {
        HtmlEmail email = new HtmlEmail();
        email.setHtmlMsg("<html><body><h1>A Title</h1></body></html>");
        email.setTextMsg("alternative message");
        EmailAttachment attachment = new EmailAttachment();
        attachment.setDescription("An image");
        attachment.setDisposition(EmailAttachment.ATTACHMENT);
        attachment.setPath(Play.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond2.png");
        EmailAttachment attachment2 = new EmailAttachment();
        attachment2.setName("fond3.jpg");
        attachment2.setPath(Play.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond3.jpg");
        email.attach(attachment);
        email.attach(attachment2);
        email.setFrom("test@localhost");
        email.addTo("test@localhost");
        email.setSubject("test attachments");
View Full Code Here

Examples of org.apache.commons.mail.EmailAttachment

*/
public class MultiPartMail {

  public static void main(String[] args) throws IOException, EmailException {
     // Create the attachment
      EmailAttachment attachment = new EmailAttachment();
      attachment.setURL(new URL("http://www.apache.org/images/asf_logo_wide.gif"));
      attachment.setDisposition(EmailAttachment.ATTACHMENT);
      attachment.setDescription("Apache logo");
      attachment.setName("Apache_logo.gif");

      // Create the email message
      MultiPartEmail email = new MultiPartEmail();
      email.setDebug(true);
      // Set email host
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.