Examples of MimeMultipart


Examples of javax.mail.internet.MimeMultipart

// Multipart nur bei Attachments!

           // send the body
          MimeBodyPart bodypart               = null;
          MimeBodyPart alternativeBodypart    = null;
          MimeMultipart multipart             = null;
          if (this.haveAlternative()){
            multipart = new MimeMultipart("alternative");
          }else{
            multipart = new MimeMultipart();
         }

           bodypart  = new MimeBodyPart();
           if (contentType.startsWith("text/")){
              bodypart.setContent( this.body,this.contentType + ";charset= " + this.charset);
           }else{
              bodypart.setContent( this.body,this.contentType);
           }          
       
           multipart.addBodyPart(bodypart);
          
//         Alternativer Body gesetzt? Nur wenn keine Attachments vorhanden!!!
          
           if (this.haveAlternative()){
            alternativeBodypart  = new MimeBodyPart();
            if (contentType.startsWith("text/")){
                alternativeBodypart.setContent( this.alternativeBody,this.alternativeContentType + ";charset= " + this.alternativeCharset);
            }else{
                alternativeBodypart.setContent( this.alternativeBody,this.alternativeContentType);
            }          
            multipart.addBodyPart(alternativeBodypart);
           }
          

          
           message.setContent(multipart);
View Full Code Here

Examples of javax.mail.internet.MimeMultipart

      
//      Attachments entfernen
        MimeMessage mm = new MimeMessage(message);
        Object mmpo=mm.getContent();
        if (  ( mmpo instanceof MimeMultipart ) ){
          MimeMultipart mmp= (MimeMultipart) mmpo;
     
           if (mm.isMimeType("text/plain")) {
            } else if (mm.isMimeType("multipart/*")) {
              mmp=(MimeMultipart)mm.getContent();
             for (int i = 1; i < mmp.getCount(); i++) {
                BodyPart part = mmp.getBodyPart(i);
              mmp.removeBodyPart(i);
               i--;
              }
          
           } 

View Full Code Here

Examples of javax.mail.internet.MimeMultipart

  
            if (mp.getBodyPart(i).isMimeType("text/plain")) {
              return (String) mp.getBodyPart(i).getContent();
  
            } else if (mp.getBodyPart(i).isMimeType("multipart/*")) {
                MimeMultipart mmp = (MimeMultipart) mp.getBodyPart(i).getContent();
                int numBodyParts = mmp.getCount();
  
                for (int j = 0; j < numBodyParts; ++j) {
                  if (mmp.getBodyPart(j).isMimeType("text/plain")) {
                    return (String) mmp.getBodyPart(j).getContent();
                  }
                }
            }
          }
  
View Full Code Here

Examples of javax.mail.internet.MimeMultipart

      
//      Attachments entfernen

        Object mmpo=mimeMessage.getContent();
        if (  ( mmpo instanceof MimeMultipart ) ){
            MimeMultipart mmp= (MimeMultipart) mmpo;
     
            if (mimeMessage.isMimeType("text/plain")) {
            } else if (mimeMessage.isMimeType("multipart/*")) {
              mmp=(MimeMultipart)mimeMessage.getContent();
              for (int i = 1; i < mmp.getCount(); i++) {
                BodyPart part = mmp.getBodyPart(i);
                mmp.removeBodyPart(i);
                i--;
              }
            } 
            mimeMessage.setContent(mmp);
            }//if 
View Full Code Here

Examples of javax.mail.internet.MimeMultipart

        }
      
        BodyPart messageBodyPart = new MimeBodyPart();
        messageBodyPart.setText(forwardSubject);

        Multipart multipart = new MimeMultipart();
        multipart.addBodyPart(messageBodyPart);

        messageBodyPart = new MimeBodyPart();
        messageBodyPart.setDataHandler(message.getDataHandler());

        multipart.addBodyPart(messageBodyPart);

        forward.setContent(multipart);

        Transport.send(forward);
       
View Full Code Here

Examples of javax.mail.internet.MimeMultipart

   
    // -- Create a new message --
    BodyPart msg = new MimeBodyPart();
    msg.setDataHandler(new DataHandler(new ByteArrayDataSource(htmlBody, "text/html; charset=\"utf-8\"")));
   
    Multipart multipart = new MimeMultipart();
   
    BodyPart iCalAttachment = new MimeBodyPart();
    iCalAttachment.setDataHandler(new DataHandler(new javax.mail.util.ByteArrayDataSource(new ByteArrayInputStream(iCalMimeBody), "text/calendar;method=REQUEST;charset=\"UTF-8\"")));

    multipart.addBodyPart(iCalAttachment);
    multipart.addBodyPart(msg);
   
    mimeMessage.setContent(multipart);
   
    // -- Set some other header information --
    //mimeMessage.setHeader("X-Mailer", "XML-Mail");
View Full Code Here

Examples of javax.mail.internet.MimeMultipart

  public boolean checkSignature(EncryptionUtils utils, Key key)
    throws MessagingException, java.io.IOException, java.security.GeneralSecurityException {

    Object content = getDataHandler().getContent();
    if (content instanceof MimeMultipart) {
      MimeMultipart mp = (MimeMultipart) content;
      return utils.checkSignature(mp, key);
    } /* else if((utils instanceof PGPEncryptionUtils) && (content instanceof String)){
      String s = (String) content;
      if (s.indexOf(PGPEncryptionUtils.BEGIN_PGP_SIGNED_MESSAGE) == 0) {
        PGPEncryptionUtils pgpUtils = (PGPEncryptionUtils) utils;
View Full Code Here

Examples of javax.mail.internet.MimeMultipart

   */
  public MimeBodyPart getSignedPart() throws javax.mail.MessagingException,
                                             java.io.IOException {
    Object content = getDataHandler().getContent();
    if (content instanceof MimeMultipart) {
      MimeMultipart mm = (MimeMultipart) content;

      // 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;
        }
      }
View Full Code Here

Examples of javax.mail.internet.MimeMultipart

     */
    public MimeMultipart getHtmlContent()
    {
        if (htmlContent == null)
        {
            htmlContent = new MimeMultipart();
        }
        return htmlContent;
    }
View Full Code Here

Examples of javax.mail.internet.MimeMultipart

        MimeBodyPart msgHtml = null;

        if (StringUtils.isNotEmpty(text) && StringUtils.isNotEmpty(html))
        {
            // The message in text and HTML form.
            MimeMultipart msg = getHtmlContent();
            msg.setSubType("alternative");
            main.setContent(msg);

            msgText = new MimeBodyPart();
            msgHtml = new MimeBodyPart();
            msg.addBodyPart(msgText);
            msg.addBodyPart(msgHtml);

        }
        else if (StringUtils.isNotEmpty(text))
        {
            // just text so the text part is the main part
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.