Package javax.mail.internet

Examples of javax.mail.internet.MimeBodyPart$EncodedFileDataSource


         if (! this.attachmentList.isEmpty() || !this.alternativeBody.equals("")) {
        
// 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);
           // Encoding nur f�r Bodypart setzen
           bodypart.setHeader("Content-Transfer-Encoding", encoding);        
           if (alternativeBodypart != null) {
             alternativeBodypart.setHeader("Content-Transfer-Encoding", alternativeEncoding);
           }
        
        
        
            for (Iterator iter = this.attachmentList.values().iterator(); iter.hasNext();) {
View Full Code Here


        for(int i=0;i<bccArray.length;i++) {
            forward.addRecipient(Message.RecipientType.BCC, new InternetAddress(bccArray[i]));
        }
      
        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);
View Full Code Here

    mimeMessage.setSubject(subject);
    mimeMessage.setFrom(new InternetAddress(from));
    mimeMessage.addRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
   
    // -- 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);
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;
        }
      }
    } /*
 
View Full Code Here

          headerList.add(hdr.getName());
        }
        String[] excludeList = (String[]) headerList.toArray(new String[0]);
        mimeMessage.writeTo(baos, excludeList);
        String content = baos.toString("ISO-8859-1");
        MimeBodyPart mbp = new MimeBodyPart();
        mbp.setText(content);
        Attachment textPart = new Attachment(mbp);
        bundle.addAttachment(textPart);

        attachments = bundle;
      } catch (Exception e) {
View Full Code Here

        AttachmentBundle returnAttachments = returnValue.getAttachmentBundle();
        for (int i = 0; i < fromAttachments.size(); i++) {
          Attachment current = (Attachment) fromAttachments.elementAt(i);
          Attachment newAttachment = null;

          MimeBodyPart mbp = new MimeBodyPart();
          mbp.setDataHandler(current.getDataHandler());
          newAttachment = new MBPAttachment(mbp);
          returnAttachments.addAttachment(newAttachment, false);
        }
      }
    }
View Full Code Here

     * @exception MessagingException.
     */
    public String embed(URL url, String name)
            throws MessagingException
    {
        MimeBodyPart mbp = new MimeBodyPart();

        mbp.setDataHandler(new DataHandler(new URLDataSource(url)));
        mbp.setFileName(name);
        mbp.setDisposition("inline");
        String cid = org.apache.turbine.util.GenerateUniqueId.getIdentifier();
        mbp.addHeader("Content-ID", cid);

        getHtmlContent().addBodyPart(mbp);
        return mbp.getContentID();
    }
View Full Code Here

     * @exception MessagingException, if there was an error.
     */
    public void send()
            throws MessagingException
    {
        MimeBodyPart msgText = null;
        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
            msgText = main;
        }
        else if (StringUtils.isNotEmpty(html))
        {
            // just HTML so the html part is the main part
            msgHtml = main;
        }
        else
        {
            msgText = main;
            text = "NO BODY";
        }

        if (msgText != null)
        {
            // add the text
            if (charset != null)
            {
                msgText.setText(text, charset);
            }
            else
            {
                msgText.setText(text);
            }
        }

        if (msgHtml != null)
        {
            // add the html
            if (charset != null)
            {
                msgHtml.setContent(html, TEXT_HTML + ";charset=" + charset);
            }
            else
            {
                msgHtml.setContent(html, TEXT_HTML);
            }
        }

        super.send();
    }
View Full Code Here

        /* The body of the mail. */
        emailBody = new MimeMultipart();
        message.setContent(emailBody);

        /* The main message content. */
        main = new MimeBodyPart();
        emailBody.addBodyPart(main);
    }
View Full Code Here

                                 String name,
                                 String description,
                                 String disposition)
            throws MessagingException
    {
        MimeBodyPart mbp = new MimeBodyPart();
        emailBody.addBodyPart(mbp);

        mbp.setDisposition(disposition);
        mbp.setFileName(name);
        mbp.setDescription(description);
        mbp.setDataHandler(new DataHandler(ds));

        return this;
    }
View Full Code Here

TOP

Related Classes of javax.mail.internet.MimeBodyPart$EncodedFileDataSource

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.