Package org.apache.james.mime4j.dom

Examples of org.apache.james.mime4j.dom.MessageWriter


        Message template = createTemplate();

        // Create a new message by transforming the template.
        Message transformed = transform(template);

        MessageWriter writer = new DefaultMessageWriter();

        // Print transformed message.
        System.out.println("\n\nTransformed message:\n--------------------\n");
        writer.writeMessage(transformed, System.out);

        // Messages should be disposed of when they are no longer needed.
        // Disposing of a message also disposes of all child elements (e.g. body
        // parts) of the message.
        transformed.dispose();

        // Print original message to illustrate that it was not affected by the
        // transformation.
        System.out.println("\n\nOriginal template:\n------------------\n");
        writer.writeMessage(template, System.out);

        // Original message is no longer needed.
        template.dispose();

        // At this point all temporary files have been deleted because all
View Full Code Here


        // note that setText also sets the Content-Type header field
        message.setText(body);

        // 4) print message to standard output

        MessageWriter writer = new DefaultMessageWriter();
        writer.writeMessage(message, System.out);

        // 5) message is no longer needed and should be disposed of

        message.dispose();
    }
View Full Code Here

        // setMultipart also sets the Content-Type header field
        message.setMultipart(multipart);

        // 4) print message to standard output

        MessageWriter writer = new DefaultMessageWriter();
        writer.writeMessage(message, System.out);

        // 5) message is no longer needed and should be disposed of

        message.dispose();
    }
View Full Code Here

        return convertFields(res);
    }

    private List<String> convertFields(List<Field> res) {
        List<String> res2 = new LinkedList<String>();
        MessageWriter mw;
        try {
            mw = newMessageBuilder().newMessageWriter();
        } catch (MimeException e1) {
            return res2;
        }
        for (Field f : res) {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            String field = null;
            try {
                mw.writeField(f, bos);
                // writeField always ends with CRLF and we don't want it.
                byte[] fieldbytes = bos.toByteArray();
                field = new String(fieldbytes, 0, fieldbytes.length - 2);
            } catch (IOException e) {
            }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.dom.MessageWriter

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.