Examples of ByteArrayDataSource


Examples of javax.mail.util.ByteArrayDataSource

//        sb.append( "<BODY>\n" );
//        sb.append( "<H1>" + subject + "</H1>" + "\n" );
        sb.append( body );
//        sb.append( "</BODY>\n" );
//        sb.append( "</HTML>\n" );
        msg.setDataHandler( new DataHandler( new ByteArrayDataSource( sb.toString(), "text/html" ) ) );
    }
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

      }
    }

    final EmailRepository repository = new EmailRepository(session);
    final MimeBodyPart messageBodyPart = repository.getBodypart();
    final ByteArrayDataSource dataSource = new ByteArrayDataSource(bout.toByteArray(), processTask.getReportMimeType());
    messageBodyPart.setDataHandler(new DataHandler(dataSource));

    final int attachmentsSize = mailDefinition.getAttachmentCount();
    for (int i = 0; i < attachmentsSize; i++)
    {
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

        client.setProperty(HttpTransport.CHUNKING_ENABLED, "true");
        // Byte array
        String result = service.stringFromBytes("tsztelak@gmail.com".getBytes());
        System.out.print("Result : "+ result+"\n");
        // Data Source
        DataSource source = new ByteArrayDataSource("tsztelak@gmail.com".getBytes(), "text/plain; charset=UTF-8");
        result = service.stringFromDataSource(source);
        System.out.print("Result : "+ result+"\n");
        // Data Handler
        result = service.stringFromDataHandler(new DataHandler(source));
        System.out.print("Result : "+ result+"\n");
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

    MimeMessage message = new MimeMessage(this.session);
    message.addRecipient(Message.RecipientType.TO, new InternetAddress("anyone@anywhere.com"));
    message.setFrom(new InternetAddress("someone@somewhereelse.com"));
    message.setSubject("hello");
    message.setHeader("Content-Transfer-Encoding", "8bit");
    message.setDataHandler(new DataHandler(new ByteArrayDataSource(body, "application/octet-stream")));

    Transport.send(message);

    InputStream in = this.wiser.getMessages().get(0).getMimeMessage().getInputStream();
    ByteArrayOutputStream tmp = new ByteArrayOutputStream();
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

      InputStream response = method.getResponseBodyAsStream();
      BufferedInputStream in = new BufferedInputStream(response);
      String contentType = method.getResponseHeader("content-type").getValue();
      System.out.println(contentType);
      ByteArrayDataSource ds = new ByteArrayDataSource(in, contentType);
      MimeMultipart mimeMultipart = new MimeMultipart(ds);
      Assert.assertEquals(mimeMultipart.getCount(), 3);
      method.releaseConnection();

   }
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

      int status = client.executeMethod(method);
      Assert.assertEquals(HttpServletResponse.SC_OK, status);
      InputStream response = method.getResponseBodyAsStream();
      BufferedInputStream in = new BufferedInputStream(response);
      String contentType = method.getResponseHeader("content-type").getValue();
      ByteArrayDataSource ds = new ByteArrayDataSource(in, contentType);
      MimeMultipart mimeMultipart = new MimeMultipart(ds);
      Assert.assertEquals(mimeMultipart.getCount(), 1);

      BodyPart part = mimeMultipart.getBodyPart(0);
      InputStream is = part.getInputStream();
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

      MultipartClient client = ProxyFactory.create(MultipartClient.class,
              generateBaseUrl());
      SimpleMimeMultipartResource.Xop xop = new SimpleMimeMultipartResource.Xop(
              new Customer("bill\u00E9"), new Customer("monica"),
              "Hello Xop World!".getBytes("UTF-8"), new DataHandler(
                      new ByteArrayDataSource("Hello Xop World!"
                              .getBytes("UTF-8"),
                              MediaType.APPLICATION_OCTET_STREAM)));
      client.putXop(xop);
   }
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

      Assert.assertEquals(HttpServletResponse.SC_OK, status);
      InputStream response = method.getResponseBodyAsStream();
      BufferedInputStream in = new BufferedInputStream(response);
      String contentType = method.getResponseHeader("content-type")
              .getValue();
      ByteArrayDataSource ds = new ByteArrayDataSource(in, contentType);
      MimeMultipart mimeMultipart = new MimeMultipart(ds);
      Assert.assertEquals(mimeMultipart.getCount(), 2);
      method.releaseConnection();
   }
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

            for (FileItem item : files) {
              MimeBodyPart attachment = new MimeBodyPart();
                attachment.setFileName(item.getFilename());
                String mimeType = MimeType.getContentTypeByExt(
                    FolderUtil.getFileExt(item.getFilename()));
                DataSource ds = new ByteArrayDataSource(item.getData(), mimeType);
                attachment.setDataHandler(new DataHandler(ds));
                mp.addBodyPart(attachment);
            }
            MimeMessage msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(fromAddress, fromText));
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

    }
  }

  protected DataSource formatResponse(byte[] response)
  {
    return new ByteArrayDataSource(response, "text/xml");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.