Package javax.mail.internet

Examples of javax.mail.internet.InternetHeaders$matchEnum


            if (!readTillFirstBoundary(stream, boundary)) {
                throw new IOException("Couldn't find MIME boundary: " + boundaryString);
            }

            try {
                message.put(InternetHeaders.class.getName(), new InternetHeaders(stream));
            } catch (MessagingException e) {
                throw new RuntimeException(e);
            }

            body = new DelegatingInputStream(new MimeBodyPartInputStream(stream, boundary, pbAmount));
View Full Code Here


            return null;
        }
        stream.unread(v);


        InternetHeaders headers;
        try {
            headers = new InternetHeaders(stream);
        } catch (MessagingException e) {
            // TODO create custom IOException
            throw new RuntimeException(e);
        }
View Full Code Here

            ByteArrayOutputStream os = new ByteArrayOutputStream();
            Writer writer = new OutputStreamWriter(
                    MimeUtility.encode(os, "quoted-printable"), "UTF-8");
            writer.write(s);
            writer.close();
            InternetHeaders headers = new InternetHeaders();
            headers.setHeader("Content-Type", layout.getContentType() + "; charset=UTF-8");
            headers.setHeader("Content-Transfer-Encoding", "quoted-printable");
            part = new MimeBodyPart(headers, os.toByteArray());
          } catch(Exception ex) {
              StringBuffer sbuf = new StringBuffer(s);
              for (int i = 0; i < sbuf.length(); i++) {
                  if (sbuf.charAt(i) >= 0x80) {
View Full Code Here

            if (!readTillFirstBoundary(stream, boundary)) {
                throw new IOException("Couldn't find MIME boundary: " + boundaryString);
            }

            try {
                InternetHeaders ih = new InternetHeaders(stream);
                message.put(InternetHeaders.class.getName(), ih);
                String val = ih.getHeader("Content-Type", "; ");
                if (!StringUtils.isEmpty(val)) {
                    String cs = HttpHeaderHelper.findCharset(val);
                    if (!StringUtils.isEmpty(cs)) {
                        message.put(Message.ENCODING, HttpHeaderHelper.mapCharset(cs));
                    }
View Full Code Here

            return null;
        }
        stream.unread(v);


        InternetHeaders headers;
        try {
            headers = new InternetHeaders(stream);
        } catch (MessagingException e) {
            // TODO create custom IOException
            throw new RuntimeException(e);
        }
View Full Code Here

         // If the stream is empty or an end marker is reached, skip to the next
         // one
         if (!advanceToHeaders(delimitedStream))
            continue;

         InternetHeaders headers = new InternetHeaders(delimitedStream);
         String typeHeader[] = headers.getHeader(MimeConstants.CONTENT_TYPE);

         if (typeHeader == null)
            throw new IllegalArgumentException("multipart/related stream invalid, component Content-type missing.");

         SwapableMemoryDataSource source = new SwapableMemoryDataSource(delimitedStream, typeHeader[0]);
         AttachmentPartImpl part = new AttachmentPartImpl(new DataHandler(source));

         Enumeration enumeration = headers.getAllHeaders();

         while (enumeration.hasMoreElements())
         {
            Header header = (Header)enumeration.nextElement();
            part.addMimeHeader(header.getName(), header.getValue());
View Full Code Here

        try {
          logger.debug("Constructing multipart");
              MimeMultipart mp = new MimeMultipart("mixed");

              logger.debug("Storing JSON response as first section");
              InternetHeaders rootHdr = new InternetHeaders();
              rootHdr.addHeader("Content-Type", "application/json");
              rootHdr.addHeader("Content-Disposition", "form-data; name=\"root-fields\"")
              byte[] rootData = jsonResponse.getBytes();
          mp.addBodyPart(new MimeBodyPart(rootHdr, rootData));
         
          logger.debug("Send second section as text attachment");             
              InternetHeaders textPartHeader = new InternetHeaders();
              textPartHeader.addHeader("Content-Type", "text/plain");
              textPartHeader.addHeader("Content-Disposition", "form-data; name=\"textpart.txt\"");
              byte[] textPartData = "Hello from OneAPI".getBytes();
              mp.addBodyPart(new MimeBodyPart(textPartHeader, textPartData));
 
          logger.debug("Send third section as html attachment");             
              InternetHeaders htmlPartHeader = new InternetHeaders();
              htmlPartHeader.addHeader("Content-Type", "text/html");
              htmlPartHeader.addHeader("Content-Disposition", "form-data; name=\"htmlpart.htm\"");
              byte[] htmlPartData = "<html><body><p><strong>Hello from OneAPI</strong></p></body></html>".getBytes();
              mp.addBodyPart(new MimeBodyPart(htmlPartHeader, htmlPartData));
             
              logger.debug("Sending status="+OK);
          response.setStatus(OK);
View Full Code Here

    private Map<String, String> getHeaders(MultipartInputStream multipart)
            throws IOException, MessagingException {
        Map<String, String> mapHeaders = new HashMap<String, String>();
        moveToHeaders(multipart);
        InternetHeaders headers = new InternetHeaders(multipart);

        Enumeration<Header> allHeaders = headers.getAllHeaders();
        if (allHeaders != null) {
            while (allHeaders.hasMoreElements()) {
                Header header = allHeaders.nextElement();
                mapHeaders.put(header.getName().toLowerCase(),
                        header.getValue());
View Full Code Here

    enc_b = Base64.encodeBase64(b);
   
    logMsg = "Encoded Byte Count: "+Integer.toString(enc_b.length);
    System.out.println("==addFileAttachmentFromStream==\n" + logMsg);
   
    InternetHeaders hdr = new InternetHeaders();
    hdr.addHeader("Content-Type", "application/octet-stream; name=\""+p_fileName+"\"");
    hdr.addHeader("Content-Transfer-Encoding", "base64");
    hdr.addHeader("Content-Disposition", "inline; filename=\""+p_fileName+"\"");
   
    MimeBodyPart mbp_file = new MimeBodyPart(hdr, enc_b);
    multipart.addBodyPart(mbp_file);
       
  }
View Full Code Here

         // If the stream is empty or an end marker is reached, skip to the next
         // one
         if (!advanceToHeaders(delimitedStream))
            continue;

         InternetHeaders headers = new InternetHeaders(delimitedStream);
         String typeHeader[] = headers.getHeader(MimeConstants.CONTENT_TYPE);

         if (typeHeader == null)
            throw new IllegalArgumentException("multipart/related stream invalid, component Content-type missing.");

         SwapableMemoryDataSource source = new SwapableMemoryDataSource(delimitedStream, typeHeader[0]);
         AttachmentPartImpl part = new AttachmentPartImpl(new DataHandler(source));

         Enumeration enumeration = headers.getAllHeaders();

         while (enumeration.hasMoreElements())
         {
            Header header = (Header)enumeration.nextElement();
            part.addMimeHeader(header.getName(), header.getValue());
View Full Code Here

TOP

Related Classes of javax.mail.internet.InternetHeaders$matchEnum

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.