Package javax.mail.internet

Examples of javax.mail.internet.ContentType


     * ��Ⱦ�ʼ����ݡ�
     */
    public void render(Part mailPart) throws MessagingException {
        String text = getText();
        String contentType = getContentType();
        ContentType contentTypeObject = MailUtil.getContentType(contentType, getMailBuilder().getCharacterEncoding());

        mailPart.setContent(text, contentTypeObject.toString());
        mailPart.setHeader(CONTENT_TRANSFER_ENCODING, DEFAULT_TRANSFER_ENCODING);
    }
View Full Code Here


    /**
     * ��ȾHTML���ݡ�
     */
    private void renderHTMLContent(Part mailPart, String text) throws MessagingException {
        String contentType = getContentType();
        ContentType contentTypeObject = MailUtil.getContentType(contentType, getMailBuilder().getCharacterEncoding());

        mailPart.setContent(text, contentTypeObject.toString());
        mailPart.setHeader(CONTENT_TRANSFER_ENCODING, DEFAULT_TRANSFER_ENCODING);
    }
View Full Code Here

     * ��Ⱦ�ʼ����ݡ�
     */
    public void render(Part mailPart) throws MessagingException {
        String text = renderTemplate();
        String contentType = getContentType();
        ContentType contentTypeObject = MailUtil.getContentType(contentType, getMailBuilder().getCharacterEncoding());

        mailPart.setContent(text, contentTypeObject.toString());
        mailPart.setHeader(CONTENT_TRANSFER_ENCODING, DEFAULT_TRANSFER_ENCODING);
    }
View Full Code Here

     * ȡ��<code>ContentType</code>����
     */
    public static ContentType getContentType(String contentType, String javaCharset) throws ParseException {
        assertNotNull(contentType, "contentType");

        ContentType contentTypeObject = new ContentType(contentType);

        javaCharset = trimToNull(javaCharset);

        if (javaCharset != null) {
            contentTypeObject.setParameter(CONTENT_TYPE_CHARSET, mimeCharset(javaCharset));
        }

        return contentTypeObject;
    }
View Full Code Here

                if (bodyObj instanceof String) {
                    String body = (String) bodyObj;
                    body = applyPatterns(rConfig.bodyPatterns, rConfig.bodySubstitutions, rConfig.bodyFlags, body, debug, this);
                    String contentType = mail.getMessage().getContentType();
                    if (charset != null) {
                        ContentType ct = new ContentType(contentType);
                        ct.setParameter("charset", charset);
                        contentType = ct.toString();
                    }
                    mail.getMessage().setContent(body, contentType);
                    mod = true;
                    contentChanged = true;
                }
            }
           
            if (charset != null && !contentChanged) {
                ContentType ct = new ContentType(mail.getMessage().getContentType());
                ct.setParameter("charset", charset);
                String contentType = mail.getMessage().getContentType();
                mail.getMessage().setContent(mail.getMessage().getContent(), contentType);
            }
           
            if (mod) mail.getMessage().saveChanges();
View Full Code Here

    }
   
    private static void setContentFromPart(Message m, Part p, String newText, boolean setTextPlain) throws MessagingException, IOException {
        String contentType = p.getContentType();
        if (setTextPlain) {
            ContentType ct = new ContentType(contentType);
            ct.setPrimaryType("text");
            ct.setSubType("plain");
            contentType = ct.toString();
        }
        m.setContent(newText != null ? newText : p.getContent(), contentType);
        String[] h = p.getHeader("Content-Transfer-Encoding");
        if (h != null && h.length > 0) m.setHeader("Content-Transfer-Encoding", h[0]);
        m.saveChanges();
View Full Code Here

        } else {
            this.fileStorageThreshold = 1;
        }
        attachmentsMap = new TreeMap();
        try {
            contentType = new ContentType(contentTypeString);
        } catch (ParseException e) {
            throw new OMException(
                    "Invalid Content Type Field in the Mime Message"
                    , e);
        }
View Full Code Here

    Object newContent = messageContent.getContent();
    if(newContent instanceof String)
      this.content = new String((String) newContent);
    else if(newContent instanceof Multipart)
    {
      ContentType ct = new ContentType(((Multipart)newContent).getContentType());
      String subType = ct.getSubType();
      Multipart multipart = new MimeMultipart(subType);
      //add parts
      for(int i=0; i < ((Multipart)newContent).getCount();i++)
      {
        multipart.addBodyPart(((Multipart)newContent).getBodyPart(i));
View Full Code Here

    contentType = message.getContentType();
    subject = message.getSubject();
    if(subject == null || subject.equals(""))
      throw new QwertoMailerException("Subject can't be null or empty");
    //get charset
    ContentType ct = new ContentType(contentType);
    charset = ct.getParameter("charset");
    if(charset == null)
      charset = "UTF-8";
  }
View Full Code Here

    if(contentType == null || contentType.length() == 0)
      throw new QwertoMailerException("Content type can't be null or empty");
   
    try
    {
      ContentType ct = new ContentType(contentType);
      this.contentType = ct.getBaseType() + "; charset=" + charset;
      ct = new ContentType(this.contentType);
    } catch (ParseException pe)
    {
      //specify that the problem relates to the ContentType
      throw new QwertoMailerException("Bad ContentType: " + pe.getMessage());
    }
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.