MimePartDataHandler mpdh = (MimePartDataHandler)dh; MimePart mpart = mpdh.getPart(); if (mpart.getEncoding() != null) is = mpdh.getContentStream(); } else { os = MimeUtility.encode(os, restrictEncoding(part, part.getEncoding())); part.getDataHandler().writeTo(os);
MimePartDataHandler mpdh = (MimePartDataHandler)dh; MimePart mpart = mpdh.getPart(); if (mpart.getEncoding() != null) is = mpdh.getContentStream(); } else { os = MimeUtility.encode(os, restrictEncoding(part, part.getEncoding())); part.getDataHandler().writeTo(os);
MimeBodyPart.restrictEncoding(part, part.getEncoding()); if (encoding != null) return MimeUtility.decode(is, encoding);
MimeBodyPart.restrictEncoding(part, part.getEncoding()); if (encoding != null) return MimeUtility.decode(is, encoding);
try { if (part.isMimeType("text/*")) { String enc = part.getEncoding(); if (enc != null && (enc.equalsIgnoreCase("quoted-printable") || enc.equalsIgnoreCase("base64"))) {
try { if (part.isMimeType("text/*")) { String enc = part.getEncoding(); if (enc != null && (enc.equalsIgnoreCase("quoted-printable") || enc.equalsIgnoreCase("base64"))) {
String enc = mpart.getEncoding(); if (enc != null) { setEncoding(part, enc); String enc = part.getEncoding(); if (enc != null && enc.equalsIgnoreCase("7bit")) charset = "us-ascii";
String enc = mpart.getEncoding(); if (enc != null) { setEncoding(part, enc); String enc = part.getEncoding(); if (enc != null && enc.equalsIgnoreCase("7bit")) charset = "us-ascii";
// 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();
public InputStream getInputStream() throws IOException { try { InputStream stream; if (part instanceof MimeMessage) { stream = ((MimeMessage) part).getContentStream(); } else if (part instanceof MimeBodyPart) { stream = ((MimeBodyPart) part).getContentStream(); } else { throw new MessagingException("Unknown part"); } String encoding = part.getEncoding(); return encoding == null ? stream : MimeUtility.decode(stream, encoding); } catch (MessagingException e) { throw (IOException) new IOException(e.getMessage()).initCause(e); } }
String encoding = part.getEncoding();
static void writeTo(MimePart part, OutputStream os, String[] ignoreList) throws IOException, MessagingException { // see if we already have a LOS LineOutputStream los = null; if (os instanceof LineOutputStream) { los = (LineOutputStream) os; } else { los = new LineOutputStream(os); } // First, write out the header Enumeration hdrLines = part.getNonMatchingHeaderLines(ignoreList); while (hdrLines.hasMoreElements()) los.writeln((String)hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); // Finally, the content. Encode if required. // XXX: May need to account for ESMTP ? os = MimeUtility.encode(os, part.getEncoding()); part.getDataHandler().writeTo(os); os.flush(); // Needed to complete encoding } }
throw new MessagingException("Unknown part"); String encoding = restrictEncoding(part.getEncoding(), part); if (encoding != null) return MimeUtility.decode(is, encoding);
MimeBodyPart.restrictEncoding(part, part.getEncoding()); if (encoding != null) return MimeUtility.decode(is, encoding);
MimeBodyPart.restrictEncoding(part, part.getEncoding()); if (encoding != null) return MimeUtility.decode(is, encoding);
MimeBodyPart.restrictEncoding(part, part.getEncoding()); if (encoding != null) return MimeUtility.decode(is, encoding);
MimeBodyPart.restrictEncoding(part, part.getEncoding()); if (encoding != null) return MimeUtility.decode(is, encoding);
MimeBodyPart.restrictEncoding(part, part.getEncoding()); if (encoding != null) return MimeUtility.decode(is, encoding);
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; }
convertTo7Bit((MimePart) parts.getBodyPart(i)); } else if ("8bit".equals(part.getEncoding())) {