Package javax.mail

Examples of javax.mail.Header


    public Enumeration getAllHeaders() throws MessagingException {
        return headers.elements();
    }

    public String getContentType() throws MessagingException {
        Header cType = (Header) headers.get("Content-Type");
        if (cType == null) {
            cType = (Header) headers.get("Content-type");
            if (cType == null) {
                cType = (Header) headers.get("content-type");
            }
        }
        return cType.getValue();
    }
View Full Code Here


  }

  private String getMessageName(Message msg) throws MessagingException {
    Enumeration headers = msg.getAllHeaders();
    while (headers.hasMoreElements()) {
      Header header = (Header) headers.nextElement();
      if (header.getName().toLowerCase().equals("message-id")) {
        String stringHeader = header.getValue();
        // System.out.println(stringHeader);
        stringHeader = stringHeader.replace("<", "");
        return stringHeader.substring(0, stringHeader.indexOf("@"));
      }
    }
View Full Code Here

        final String ct = headers.getHeader("Content-Type", null);
       
        boolean quotedPrintable = false;
       
        for (Enumeration<?> e = headers.getAllHeaders(); e.hasMoreElements();) {
            Header header = (Header) e.nextElement();
            if (header.getName().equalsIgnoreCase("Content-Transfer-Encoding")) {
                if (header.getValue().equalsIgnoreCase("binary")) {
                    att.setXOP(true);
                } else if (header.getValue().equalsIgnoreCase("quoted-printable")) {
                    quotedPrintable = true;
                }
            }
            att.setHeader(header.getName(), header.getValue());
        }
       
        if (quotedPrintable) {
            DataSource source = new AttachmentDataSource(ct,
                                                         new QuotedPrintableDecoderStream(stream));
View Full Code Here

    boolean cTransferEncFound = false;
    boolean cIdFound = false;
    boolean snhFound = false;

    while (e.hasMoreElements()) {
      Header h = (Header) e.nextElement();
      if (h.getName().toLowerCase().equals("content-type")) {
        cTypeFound = true;
      }
     
      if (h.getName().toLowerCase().equals("content-transfer-encoding")) {
        cTransferEncFound = true;
      }
     
      if (h.getName().toLowerCase().equals("content-id")) {
        cIdFound = true;
      }
     
      if (h.getName().toLowerCase().equals("some-new-header")) {
        snhFound = true;
      }
    }
   
    if (!cTypeFound || !cTransferEncFound || !cIdFound || !snhFound) {
View Full Code Here

        final String ct = headers.getHeader("Content-Type", null);
       
        boolean quotedPrintable = false;
       
        for (Enumeration<?> e = headers.getAllHeaders(); e.hasMoreElements();) {
            Header header = (Header) e.nextElement();
            if (header.getName().equalsIgnoreCase("Content-Transfer-Encoding")) {
                if (header.getValue().equalsIgnoreCase("binary")) {
                    att.setXOP(true);
                } else if (header.getValue().equalsIgnoreCase("quoted-printable")) {
                    quotedPrintable = true;
                }
            }
            att.setHeader(header.getName(), header.getValue());
        }
       
        if (quotedPrintable) {
            DataSource source = new AttachmentDataSource(ct,
                                                         new QuotedPrintableDecoderStream(stream));
View Full Code Here

    protected Map<String, Object> extractHeadersFromMail(Message mailMessage) throws MessagingException {
        Map<String, Object> answer = new HashMap<String, Object>();
        Enumeration names = mailMessage.getAllHeaders();

        while (names.hasMoreElements()) {
            Header header = (Header)names.nextElement();
            String[] value = mailMessage.getHeader(header.getName());
            if (headerFilterStrategy != null
                    && !headerFilterStrategy.applyFilterToExternalHeaders(header.getName(), value)) {
                // toLowerCase() for doing case insensitive search
                if (value.length == 1) {
                    CollectionHelper.appendValue(answer, header.getName().toLowerCase(), value[0]);
                } else {
                    CollectionHelper.appendValue(answer, header.getName().toLowerCase(), value);
                }
            }
        }

        return answer;
View Full Code Here

        String fileName = getContentDispositionFileName(cd);
       
        boolean quotedPrintable = false;
       
        for (Enumeration<?> e = headers.getAllHeaders(); e.hasMoreElements();) {
            Header header = (Header) e.nextElement();
            if (header.getName().equalsIgnoreCase("Content-Transfer-Encoding")) {
                if (header.getValue().equalsIgnoreCase("binary")) {
                    att.setXOP(true);
                } else if (header.getValue().equalsIgnoreCase("quoted-printable")) {
                    quotedPrintable = true;
                }
            }
            att.setHeader(header.getName(), header.getValue());
        }
       
        if (quotedPrintable) {
            DataSource source = new AttachmentDataSource(ct,
                                                         new QuotedPrintableDecoderStream(stream));
View Full Code Here

        final String ct = headers.getHeader("Content-Type", null);
       
        boolean quotedPrintable = false;
       
        for (Enumeration<?> e = headers.getAllHeaders(); e.hasMoreElements();) {
            Header header = (Header) e.nextElement();
            if (header.getName().equalsIgnoreCase("Content-Transfer-Encoding")) {
                if (header.getValue().equalsIgnoreCase("binary")) {
                    att.setXOP(true);
                } else if (header.getValue().equalsIgnoreCase("quoted-printable")) {
                    quotedPrintable = true;
                }
            }
            att.setHeader(header.getName(), header.getValue());
        }
       
        if (quotedPrintable) {
            DataSource source = new AttachmentDataSource(ct,
                                                         new QuotedPrintableDecoderStream(stream));
View Full Code Here

    public String getHeader(String arg0) throws MessagingException {
      return (String) ((Header) headers.get(arg0)).getValue();
    }

    public void addHeader(String arg0, String arg1) throws MessagingException {
      Header headerObj = new Header(arg0, arg1);
        headers.put(arg0, headerObj);
    }
View Full Code Here

    public Enumeration getAllHeaders() throws MessagingException {
        return headers.elements();
    }

    public String getContentType() throws MessagingException {
        Header cType = (Header) headers.get("Content-Type");
        if (cType == null) {
            cType = (Header) headers.get("Content-type");
            if (cType == null) {
                cType = (Header) headers.get("content-type");
            }
        }
        return (String) cType.getValue();
    }
View Full Code Here

TOP

Related Classes of javax.mail.Header

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.