Package javax.mail.internet

Examples of javax.mail.internet.ContentType


                // Extract the charset encoding from the configured content type and
                // set the CHARACTER_SET_ENCODING property as e.g. SOAPBuilder relies on this.
                String charSetEnc = null;
                try {
                    if (contentType != null) {
                        charSetEnc = new ContentType(contentType).getParameter("charset");
                    }
                } catch (ParseException ex) {
                    // ignore
                }
                msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
View Full Code Here


      if (level > 0 && p instanceof Message)
         dumpEnvelope((Message) p, level);

      String ct = p.getContentType();
      try {
         pr("CONTENT-TYPE: " + (new ContentType(ct)).toString(), level);
      } catch (ParseException pex) {
         pr("BAD CONTENT-TYPE: " + ct, level);
      }
      String filename = p.getFileName();
      if (filename != null)
View Full Code Here

      // this should be exactly two parts, one the content, the other the
      // signature.
      for (int i = 0; i < mm.getCount(); i++) {
        // return the first one found.
        MimeBodyPart mbp = (MimeBodyPart) mm.getBodyPart(i);
        ContentType ct = new ContentType(mbp.getContentType());
        if (! ct.getSubType().toLowerCase().endsWith("signature")) {
          return mbp;
        }
      }
    } /*
    else if(content instanceof String){
View Full Code Here

        return type;
    }

    public void setType(String type) {
        try {
            new ContentType(type);
            if (log.isDebugEnabled()) {
                log.debug("Content type :" + type);
            }
            this.type = type;
        } catch (ParseException e) {
View Full Code Here

                // Extract the charset encoding from the configured content type and
                // set the CHARACTER_SET_ENCODING property as e.g. SOAPBuilder relies on this.
                String charSetEnc = null;
                try {
                    if (contentType != null) {
                        charSetEnc = new ContentType(contentType).getParameter("charset");
                    }
                } catch (ParseException ex) {
                    // ignore
                }
                msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
View Full Code Here

     * @param contentType
     * @return
     * @throws ParseException
     */
    protected String getCharSet(String contentType) throws ParseException {
        ContentType type = new ContentType(contentType);
        String charset = type.getParameter("charset");
        if (charset == null) {
            charset = "us-ascii";
        }
        return MimeUtility.javaCharset(charset);
    }
View Full Code Here

        return contentType;
    }
   
    private String getParameter(String name) {
        try {
            return new ContentType(contentType).getParameter(name);
        } catch (ParseException ex) {
            // MIMEResource objects are only defined as constants. Therefore we
            // will never get here under normal conditions.
            throw new Error(ex);
        }
View Full Code Here

          LOGGER.info(String.format("Handdling attachment '%s', type: '%s'", filename, contentType));
        }
        else {

          final String textFilename;
          final ContentType ct;

          try {
            ct = new ContentType(contentType);
          }
          catch (ParseException e) {
            throw new IllegalStateException("Error while parsing content type '" + contentType + "'.", e);
          }

          if ("text/plain".equalsIgnoreCase(ct.getBaseType())) {
            textFilename = "message.txt";
          }
          else if ("text/html".equalsIgnoreCase(ct.getBaseType())) {
            textFilename = "message.html";
          }
          else {
            textFilename = "message.other";
          }
View Full Code Here

      this.fileName = filename;
    }

    // get mime type
    try {
      ContentType cType = new ContentType(part.getContentType());
      mimeType = cType.getBaseType();
    } catch (Exception e) {
      logger.warn("parser was unable to decode not well-formed Content-Type: {}", e.getMessage());
    } finally {
      this.mimeType = mimeType;
    }
View Full Code Here

        // Extract the charset encoding from the configured content type and
        // set the CHARACTER_SET_ENCODING property as e.g. SOAPBuilder relies on this.
        String charSetEnc;
        try {
            charSetEnc = new ContentType(contentType).getParameter("charset");
        } catch (ParseException ex) {
            // ignore
            charSetEnc = null;
        }
        msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
View Full Code Here

TOP

Related Classes of javax.mail.internet.ContentType

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.