Package javax.mail.internet

Examples of javax.mail.internet.MimeMultipart.addBodyPart()


    bp2.setDataHandler(dh);
    bp2.setFileName(fileAttachment.getName());

    Multipart multipart = new MimeMultipart();
    multipart.addBodyPart(bp1);
    multipart.addBodyPart(bp2);

    baseMsg.setFrom(new InternetAddress("Ted <ted@home.com>"));
    baseMsg.setRecipient(Message.RecipientType.TO, new InternetAddress(
        "success@subethamail.org"));
    baseMsg.setSubject("Test Big attached file message");
View Full Code Here


        InputStream oLongVarBin = oRSet.getBinaryStream(17);

        if (!oRSet.wasNull()) {
          if (DebugFile.trace) DebugFile.writeln("MimeMultipart.addBodyPart(new MimeBodyPart(InputStream)");
          oParts.addBodyPart(new MimeBodyPart(oLongVarBin));
        }

        oRSet.close();
        oRSet = null;
View Full Code Here

        oMsgBodyPart.setText(oReplaced, "UTF-8", "html");

        // Create a related multi-part to combine the parts
        MimeMultipart oRelatedMultiPart = new MimeMultipart("related");
        oRelatedMultiPart.addBodyPart(oMsgBodyPart);

        Iterator<String> oImgs = oDocumentImages.keySet().iterator();

        while (oImgs.hasNext()) {
          MimeBodyPart oImgBodyPart = new MimeBodyPart();
View Full Code Here

          oImgBodyPart.setContentID(sCid);
          oImgBodyPart.setDisposition(oImgBodyPart.INLINE);
          oImgBodyPart.setFileName(sCid);

          // Add part to multi-part
          oRelatedMultiPart.addBodyPart(oImgBodyPart);
        } // wend

        MimeBodyPart oTextHtmlRelated = new MimeBodyPart();
        oTextHtmlRelated.setContent(oRelatedMultiPart);
View Full Code Here

      MimeMultipart oSentMsgParts = new MimeMultipart("mixed");
     MimeBodyPart oMixedPart = new MimeBodyPart();
       
        oMixedPart.setContent(oAltParts);
        oSentMsgParts.addBodyPart(oMixedPart);
       
        oMsg.setContent(oSentMsgParts);
      }

      else {
View Full Code Here

        // with attachment use multipart message
        Multipart multipart = new MimeMultipart();
        // 1) add body part
        BodyPart messageBodyPart = new MimeBodyPart();
        messageBodyPart.setText(body);
        multipart.addBodyPart(messageBodyPart);
        // 2) add attachments
        for (File attachmentFile : attachments) {
          // abort if attachment does not exist
          if (attachmentFile == null || !attachmentFile.exists()) {
            result.setReturnCode(MailerResult.ATTACHMENT_INVALID);
View Full Code Here

          }
          messageBodyPart = new MimeBodyPart();
          DataSource source = new FileDataSource(attachmentFile);
          messageBodyPart.setDataHandler(new DataHandler(source));
          messageBodyPart.setFileName(attachmentFile.getName());
          multipart.addBodyPart(messageBodyPart);
        }
        // Put parts in message
        msg.setContent(multipart);
      } else {
        // without attachment everything is easy, just set as text
View Full Code Here

        try {
          Multipart mp = new MimeMultipart();
          MimeBodyPart htmlPart = new MimeBodyPart();
            htmlPart.setContent(htmlBody, "text/html");
            htmlPart.setHeader("Content-type", "text/html; charset=UTF-8");
            mp.addBodyPart(htmlPart);
            for (FileItem item : files) {
              MimeBodyPart attachment = new MimeBodyPart();
                attachment.setFileName(item.getFilename());
                String mimeType = MimeType.getContentTypeByExt(
                    FolderUtil.getFileExt(item.getFilename()));
View Full Code Here

                attachment.setFileName(item.getFilename());
                String mimeType = MimeType.getContentTypeByExt(
                    FolderUtil.getFileExt(item.getFilename()));
                DataSource ds = new ByteArrayDataSource(item.getData(), mimeType);
                attachment.setDataHandler(new DataHandler(ds));
                mp.addBodyPart(attachment);
            }
            MimeMessage msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(fromAddress, fromText));
            msg.addRecipient(Message.RecipientType.TO,
                             new InternetAddress(toAddress, toAddress));
View Full Code Here

              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();
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.