/** * Write the headers to an output stream * * @param out the OutputStream to which to write the headers */ public void writeTo(OutputStream out) throws MessagingException{ MimeMessageUtil.writeHeadersTo(getAllHeaderLines(), out); }
/** * Write the message headers to the given outputstream * * @param message the MimeMessage to read from * @param headerOs the OutputStream to which the headers get written * @param ignoreList the String[] which holds headers which should be ignored * @throws MessagingException */ private static void writeHeadersTo(MimeMessage message, OutputStream headerOs, String[] ignoreList) throws MessagingException { //Write the headers (minus ignored ones) Enumeration headers = message.getNonMatchingHeaderLines(ignoreList); writeHeadersTo(headers, headerOs); }
/** * * @param message * @param headerOs * @param bodyOs * @param ignoreList * @throws MessagingException * @throws IOException * @throws UnsupportedDataTypeException */ public static void writeToInternal(MimeMessage message, OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws MessagingException, IOException, UnsupportedDataTypeException { if(message.getMessageID() == null) { message.saveChanges(); } writeHeadersTo(message, headerOs, ignoreList); // Write the body to the output stream writeMessageBodyTo(message, bodyOs); }