private void setHtmlTextToMimePart(MimePart mimePart, String text) throws MessagingException { if (getEncoding() != null) { mimePart.setContent(text, CONTENT_TYPE_HTML + CONTENT_TYPE_CHARSET_SUFFIX + getEncoding()); } else { mimePart.setContent(text, CONTENT_TYPE_HTML); } }
/** * Creates a MimePart from HTML part. * * @return mimePart from HTML part * @throws MessagingException */ private MimePart createHtmlMimePart() throws MessagingException { MimePart bodyPart = new MimeBodyPart(); bodyPart.setContent(htmlPart, "text/html; charset=utf-8"); return bodyPart; }
private void setHtmlTextToMimePart(MimePart mimePart, String text) throws MessagingException { if (getEncoding() != null) { mimePart.setContent(text, CONTENT_TYPE_HTML + CONTENT_TYPE_CHARSET_SUFFIX + getEncoding()); } else { mimePart.setContent(text, CONTENT_TYPE_HTML); } }
static void setText(MimePart part, String text, String charset, String subtype) throws MessagingException { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset(); else charset = "us-ascii"; } // XXX - should at least ensure that subtype is an atom part.setContent(text, "text/" + subtype + "; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
Multipart multipart = new MimeMultipart(); bodyPart = new MimeBodyPart(); bodyPart.setContent(body, type); for (DataSource attachment : attachments) { MimeBodyPart attachmentPart = new MimeBodyPart(); bodyPart.setContent(body, type); } else { bodyPart.setText(body.toString());
static void setText(MimePart part, String text, String charset, String subtype) throws MessagingException { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset(); else charset = "us-ascii"; } // XXX - should at least ensure that subtype is an atom part.setContent(text, "text/" + subtype + "; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
part.setContent(part.getContent(), part.getContentType()); part.setHeader("Content-Transfer-Encoding", "8bit");
part.setContent(part.getContent(), part.getContentType()); part.setHeader("Content-Transfer-Encoding", "8bit");
private void setHtmlTextToMimePart(MimePart mimePart, String text) throws MessagingException { if (getEncoding() != null) { mimePart.setContent(text, CONTENT_TYPE_HTML + CONTENT_TYPE_CHARSET_SUFFIX + getEncoding()); } else { mimePart.setContent(text, CONTENT_TYPE_HTML); } }
static void setText(MimePart part, String text, String charset, String subtype) throws MessagingException { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset(); else charset = "us-ascii"; } // XXX - should at least ensure that subtype is an atom part.setContent(text, "text/" + subtype + "; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
static void setText(MimePart part, String text, String charset, String subtype) throws MessagingException { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset(); else charset = "us-ascii"; } // XXX - should at least ensure that subtype is an atom part.setContent(text, "text/" + subtype + "; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
static void setText(MimePart part, String text, String charset, String subtype) throws MessagingException { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset(); else charset = "us-ascii"; } // XXX - should at least ensure that subtype is an atom part.setContent(text, "text/" + subtype + "; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
static void setText(MimePart part, String text, String charset, String subtype) throws MessagingException { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset(); else charset = "us-ascii"; } // XXX - should at least ensure that subtype is an atom part.setContent(text, "text/" + subtype + "; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
static void setText(MimePart part, String text, String charset, String subtype) throws MessagingException { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset(); else charset = "us-ascii"; } // XXX - should at least ensure that subtype is an atom part.setContent(text, "text/" + subtype + "; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
static void setText(MimePart part, String text, String charset, String subtype) throws MessagingException { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset(); else charset = "us-ascii"; } // XXX - should at least ensure that subtype is an atom part.setContent(text, "text/" + subtype + "; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
static void setText(MimePart part, String text, String charset, String subtype) throws MessagingException { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset(); else charset = "us-ascii"; } // XXX - should at least ensure that subtype is an atom part.setContent(text, "text/" + subtype + "; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
static void setText(MimePart part, String text, String charset, String subtype) throws MessagingException { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset(); else charset = "us-ascii"; } // XXX - should at least ensure that subtype is an atom part.setContent(text, "text/" + subtype + "; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
// source is the encrypted MimeMessage // MimeMessageWrapper is a wrapper which can copy a messgae but keep the message ID unchanged boolean keepMessageId = true; MimeMessageWrapper newMime = new MimeMessageWrapper(source, keepMessageId); MimeMultipart mmp = new MimeMultipart("mixed"); List<MimePart> parts = MimeMultipartUtils.findPartsByMimeType(mime, "*"); for (MimePart part : parts) { // Do some part processing // Decrypt Adn verify individual parts // End of processing ContentType type = new ContentType(part.getContentType()); String encoding = part.getEncoding(); String name = type.getParameter("name"); part.setContent(new String(decPart.toByteArray()), type.toString()); // Add the part to the brand new MimeMultipart mmp.addBodyPart((BodyPart) part); } // Set the original copy Message with the new modified content (decrypted parts) mime.setContent(mmp); mime.saveChanges();
/** * Prepends the content of the MimePart as text to the existing footer * * @param part the MimePart to attach * * @throws MessagingException * @throws IOException */ protected void addToText(MimePart part) throws MessagingException, IOException { // log("Trying to add footer to " + part.getContent().toString()); String contentType = part.getContentType(); String content = (String) part.getContent(); if (!content.endsWith("\n")) { content += "\r\n"; } content += getFooterText(); part.setContent(content, contentType); part.setHeader(RFC2822Headers.CONTENT_TYPE, contentType); // log("After adding footer: " + part.getContent().toString()); }
public MimePart convertTo7Bit(MimePart part) throws MessagingException, IOException { if (part.isMimeType("multipart/*")) { List<BodyPart> bodyParts = MultipartUtil.retrieveBodyParts((MimeMultipart) part.getContent()); for (BodyPart bodyPart : bodyParts) { convertTo7Bit((MimePart) bodyPart); } } else if ("8bit".equals(part.getEncoding())) { // The content may already be in encoded the form (likely with mail // created from a // stream). In that case, just changing the encoding to // quoted-printable will mangle // the result when this is transmitted. We must first convert the // content into its // native format, set it back, and only THEN set the transfer // encoding to force the // content to be encoded appropriately. // if the part doesn't contain text it will be base64 encoded. String contentTransferEncoding = part.isMimeType("text/*") ? "quoted-printable" : "base64"; part.setContent(part.getContent(), part.getContentType()); part.setHeader("Content-Transfer-Encoding", contentTransferEncoding); part.addHeader("X-MIME-Autoconverted", "from 8bit to " + contentTransferEncoding + " by " + mailetContext.getServerInfo()); } return part; }