Package javax.mail.internet

Examples of javax.mail.internet.MimeMessage.saveChanges()


                        mbp.setFileName(fileName);
                    }
                    mp.addBodyPart(mbp);
                }
                mail.setContent(mp);
                mail.saveChanges();
            } else {
                // create the singelpart message
                if (contentType.startsWith("text")) {
                    mail.setText(body, "UTF-8", contentType.substring(5));
                } else {
View Full Code Here


                if (contentType.startsWith("text")) {
                    mail.setText(body, "UTF-8", contentType.substring(5));
                } else {
                    mail.setContent(body, contentType);
                }
                mail.saveChanges();
            }
        } catch (MessagingException e) {
            Debug.logError(e, "MessagingException when creating message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]", module);
            Debug.logError("Email message that could not be created to [" + sendTo + "] had context: " + context, module);
            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendMessagingException", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale));
View Full Code Here

      bodyPart.setFileName(e.getValue());
      bodyPart.setHeader("Content-ID", e.getValue());
      multipart.addBodyPart(bodyPart);
    }
    message.setContent(multipart);
    message.saveChanges();
    Transport.send(message, message.getAllRecipients());
    Misc.getLogger().info("Send Mail success!");
  }

  private void setSMTPHost(String smtpHost) {
View Full Code Here

      bodyPart.setFileName(e.getValue());
      bodyPart.setHeader("Content-ID", e.getValue());
      multipart.addBodyPart(bodyPart);
    }
    message.setContent(multipart);
    message.saveChanges();
    Transport.send(message, message.getAllRecipients());
  }

  private void setSMTPHost(String smtpHost) {
    if (smtpHost == null) {
View Full Code Here

        this.email.setCharset("ISO-8859-1");
        this.email.setContent("test content", "text/plain");
        this.email.buildMimeMessage();
        MimeMessage msg = this.email.getMimeMessage();
        msg.saveChanges();
        assertEquals("text/plain; charset=ISO-8859-1", msg.getContentType());
    }

    /**
     * Case 2:
View Full Code Here

        this.email.setCharset("ISO-8859-1");
        this.email.setContent("test content", "text/plain; charset=US-ASCII");
        this.email.buildMimeMessage();
        MimeMessage msg = this.email.getMimeMessage();
        msg.saveChanges();
        assertEquals("text/plain; charset=US-ASCII", msg.getContentType());
    }

    /**
     * Case 3:
View Full Code Here

        this.email.setCharset("ISO-8859-1");
        this.email.setContent("test content", "application/octet-stream");
        this.email.buildMimeMessage();
        MimeMessage msg = this.email.getMimeMessage();
        msg.saveChanges();
        assertEquals("application/octet-stream", msg.getContentType());
    }
}
View Full Code Here

                        mbp.setFileName(fileName);
                    }
                    mp.addBodyPart(mbp);
                }
                mail.setContent(mp);
                mail.saveChanges();
            } else {
                // create the singelpart message
                if (contentType.startsWith("text")) {
                    mail.setText(body, "UTF-8", contentType.substring(5));
                } else {
View Full Code Here

                if (contentType.startsWith("text")) {
                    mail.setText(body, "UTF-8", contentType.substring(5));
                } else {
                    mail.setContent(body, contentType);
                }
                mail.saveChanges();
            }
        } catch (MessagingException e) {
            String errMsg = "MessagingException when creating message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]";
            Debug.logError(e, errMsg, module);
            Debug.logError("Email message that could not be created to [" + sendTo + "] had context: " + context, module);
View Full Code Here

        mime.setContent(parts);
        mime.setHeader(Message.CONTENT_TYPE, parts.getContentType());
        // We do not want headers, so
        //  * retrieve all headers
        //  * skip first 2 bytes (CRLF)
        mime.saveChanges();
        Enumeration<Header> headersEnum = mime.getAllHeaders();
        List<String> headersList = new ArrayList<String>();
        while (headersEnum.hasMoreElements()) {
            headersList.add(headersEnum.nextElement().getName().toLowerCase());
        }
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.