Package org.apache.james.mime4j.storage

Examples of org.apache.james.mime4j.storage.StorageBodyFactory


    /*
     * taken from http://svn.apache.org/repos/asf/james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
     */
    private static BodyPart createTextBody(String text, String subtype, boolean isAttachment) {
        TextBody body = new StorageBodyFactory().textBody(text, MailArchiveServerConstants.DEFAULT_ENCODER.charset().name());

        BodyPart bodyPart = new BodyPart();
        if (isAttachment) {
            bodyPart.setContentDisposition("attachment", "file"+Math.random());
        }
View Full Code Here


     */
    private static BodyPart createRandomBinaryAttachment(int numberOfBytes) throws IOException {
        byte[] data = new byte[numberOfBytes];
        new Random().nextBytes(data);

        Body body = new StorageBodyFactory().binaryBody(new ByteArrayInputStream(data));

        BodyPart bodyPart = new BodyPart();
        bodyPart.setContentDisposition("attachment", "file"+Math.random());
        bodyPart.setBody(body, "application/octet-stream");

View Full Code Here

        // a multipart may have a preamble
        multipart.setPreamble("This is a multi-part message in MIME format.");

        // first part is text/plain
        StorageBodyFactory bodyFactory = new StorageBodyFactory();
        BodyPart textPart = createTextPart(bodyFactory, "Why so serious?");
        multipart.addBodyPart(textPart);

        // second part is image/png (image is created on the fly)
        BufferedImage image = renderSampleImage();
View Full Code Here

    /**
     * Creates a text part from the specified string.
     */
    private static BodyPart createTextPart(String text) {
        TextBody body = new StorageBodyFactory().textBody(text, "UTF-8");

        BodyPart bodyPart = new BodyPart();
        bodyPart.setText(body);
        bodyPart.setContentTransferEncoding("quoted-printable");

View Full Code Here

    private static BodyPart createRandomBinaryPart(int numberOfBytes)
            throws IOException {
        byte[] data = new byte[numberOfBytes];
        new Random().nextBytes(data);

        Body body = new StorageBodyFactory()
                .binaryBody(new ByteArrayInputStream(data));

        BodyPart bodyPart = new BodyPart();
        bodyPart.setBody(body, "application/octet-stream");
        bodyPart.setContentTransferEncoding("base64");
View Full Code Here

        message.setTo(AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>"));
        message.setSubject("Saying Hello");

        // 3) set a text body

        StorageBodyFactory bodyFactory = new StorageBodyFactory();
        TextBody body = bodyFactory.textBody("This is a message just to "
                + "say hello.\r\nSo, \"Hello\".");

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

TOP

Related Classes of org.apache.james.mime4j.storage.StorageBodyFactory

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.