Package org.apache.commons.mail

Examples of org.apache.commons.mail.MultiPartEmail


        // /////////////////////////////////////////////////////////////////////
        Mail mail = new MailImpl();
        // set only text:
        mail.setBodyText("simple body text");

        MultiPartEmail multiPartEmail = commonsmailHelper.createMultiPartEmailWithContent(mail);

        assertTrue(multiPartEmail instanceof MultiPartEmail);

        // /////////////////////////////////////////////////////////////////////
        // Test with html only content
View Full Code Here


    @Override
    public void send(Mail mail) throws Exception {

        // create a correct multipart email based on html / txt content:
        MultiPartEmail multiPartEmail = commonsmailHelper.createMultiPartEmailWithContent(mail);

        // fill the from, to, bcc, css and all other fields:
        commonsmailHelper.doPopulateMultipartMailWithContent(multiPartEmail, mail);

        // set server parameters so we can send the MultiPartEmail:
        commonsmailHelper.doSetServerParameter(multiPartEmail, smtpHost, smtpPort, smtpSsl,
                smtpUser, smtpPassword, smtpDebug);

        // And send it:
        multiPartEmail.send();
    }
View Full Code Here

     * Populates the mutlipart email accordingly with the txt / html content.
     */
    @Override
    public MultiPartEmail createMultiPartEmailWithContent(Mail mail) throws EmailException {

        MultiPartEmail multiPartEmail;

        // set if it is a txt or html mail:

        if (mail.getBodyHtml() == null || mail.getBodyHtml().equals("")) {

            multiPartEmail = new MultiPartEmail();
            multiPartEmail.setMsg(mail.getBodyText());

        } else if (mail.getBodyText() == null || mail.getBodyText().equals("")) {
            multiPartEmail = new HtmlEmail().setHtmlMsg(mail.getBodyHtml());
        } else {
            multiPartEmail =
View Full Code Here

      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))
      {
        email.setSSL(true);
        email.setSslSmtpPort(this.smtpPort.toString());
      }
      else
      {
        email.setSSL(false);
        email.setSmtpPort(this.smtpPort);
      }
      email.addTo(toEmail);
      email.setFrom(this.smtpFromAddress);
      email.setSubject(subject);
      email.setMsg(body);
      email.setAuthentication(this.smtpUser, (deObf ? HtmlTools.fromSafeUrlStringO_b_f(smtpAu) : smtpAu));
     
      // add the attachment
      email.attach(attachment);
     
      // send the email
      email.send();
     
      return true;
    }
    catch (Exception e)
    {
View Full Code Here

      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
      email.setHostName("10.7.2.18");
//      email.setAuthentication("nice_to_meet", "asf_logo_me");
//      email.setSSL(true);
      // Set email from
      email.setFrom("lei.gao@renren-inc.com", "Commons Email");
      email.setBounceAddress("lei.gao@renren-inc.com");
      // Set email content
      email.addTo("jiyun.xie@renren-inc.com", "Jiyun Xie");
      email.addTo("lei.gao@renren-inc.com", "Lei Gao");
      email.setSubject("Foll Alert The Git test");
      email.setMsg("Here is Apache's logo, please enjoy it!");

      // add the attachment
      email.attach(attachment);

      // send the email
      email.send();
  }
View Full Code Here

//                    if (!StringUtils.isEmpty(bodyText)) {
//                        htmlEmail.setTextMsg(bodyText);
//                    }
                    email = htmlEmail;
//                }
                MultiPartEmail multiPartEmail = (MultiPartEmail) email;
                List<EmailAttachment> objectList = (List<EmailAttachment>) infoMap.get(ATTACHMENTS);
                for (EmailAttachment object : objectList) {
                    multiPartEmail.attach(object);
                }
            }

            if (from != null) {
                try {
View Full Code Here

    if(MailActionService.isProperlyConfigured) {
      Email email = new SimpleEmail();
      if(attachmentUrl!=null) {
        // Create the attachment
          try {
            email = new MultiPartEmail();
            EmailAttachment attachment = new EmailAttachment();
            attachment.setURL(new URL(attachmentUrl));
            attachment.setDisposition(EmailAttachment.ATTACHMENT);
            attachment.setName("Attachment");
            ((MultiPartEmail) email).attach(attachment);
View Full Code Here

    @Override
    public void send(Mail mail) throws Exception {

        // create a correct multipart email based on html / txt content:
        MultiPartEmail multiPartEmail = commonsmailHelper
                .createMultiPartEmailWithContent(mail);

        // fill the from, to, bcc, css and all other fields:
        commonsmailHelper.doPopulateMultipartMailWithContent(multiPartEmail,
                mail);

        // And send it:
        multiPartEmail.setMailSession(session);
        multiPartEmail.send();
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.mail.MultiPartEmail

Copyright © 2018 www.massapicom. 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.