Package javax.mail

Examples of javax.mail.Multipart


     
      msg.setSubject(eMessage.getSubject());
      MimeBodyPart mbp = new MimeBodyPart();
      mbp.setText(eMessage.getHtmlContents(), "us-ascii");
      msg.setHeader("X-Mailer", "JavaMailer");
      Multipart mp = new MimeMultipart();
      mp.addBodyPart(mbp);
      msg.setContent(mp);
      msg.setSentDate(new Date());
     
      Transport.send(msg);
     
View Full Code Here


                              new InternetAddress( userInfo.getEmailForEntity( owner ) ) );
        message.setSubject( "Task Assignment " + type + " Event: " + name );
        message.setSentDate( new Date() );

        // Create a Multipart
        Multipart multipart = new MimeMultipart( "alternative" );

        // Add text message
        BodyPart messageBodyPart = new MimeBodyPart();
        String text = "Summary\n-------\n\n" + summary + "\n\nDescription\n-----------\n\n" + description;
        messageBodyPart.setText( text );
        messageBodyPart.setDataHandler( new DataHandler( new ByteArrayDataSource( text,
                                                                                  "text/plain; charset=UTF8;" ) ) );
        multipart.addBodyPart( messageBodyPart );

        // Add ical
        messageBodyPart = new MimeBodyPart();
        String filename = "ical-" + type + "-" + taskId + ".ics";
        messageBodyPart.setFileName( filename );
        messageBodyPart.setHeader( "Content-Class",
                                   "urn:content-classes:calendarmessage" );
        messageBodyPart.setHeader( "Content-ID",
                                   "calendar_message" );
        String icalStr = getIcal( summary,
                                  description,
                                  startDate,
                                  priority,
                                  userInfo.getDisplayName( creator ),
                                  creatorEmail,
                                  type );

        messageBodyPart.setDataHandler( new DataHandler( new ByteArrayDataSource( icalStr,
                                                                                  "text/calendar; charset=UTF8; " ) ) );
        multipart.addBodyPart( messageBodyPart );

        message.setContent( multipart );
        message.saveChanges();

        Transport.send( message );
View Full Code Here

                .getSubType(contentType));
      } else {
        part.setContent(sbuf.toString(), layout.getContentType());
      }

      Multipart mp = new MimeMultipart();
      mp.addBodyPart(part);
      mimeMsg.setContent(mp);

      mimeMsg.setSentDate(new Date());
      Transport.send(mimeMsg);
    } catch (Exception e) {
View Full Code Here

        BodyPart messageBodyPart = new MimeBodyPart();

        // Fill the message
        messageBodyPart.setText(_content == null ? "" : _content);

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

        if (_attachment1 != null)
          _addAttachment(multipart, _attachment1);
        if (_attachment2 != null)
          _addAttachment(multipart, _attachment2);
View Full Code Here

                    a = this.body;
                    a.setContentTo(resolver, sources, message);
                }
            } else {
                // Message consists of multiple parts
                Multipart multipart = new MimeMultipart();
                message.setContent(multipart);

                // Body part
                if (this.body != null) {
                    a = this.body;
                    multipart.addBodyPart(a.getBodyPart(resolver, sources));
                }

                // Attachment parts
                for (Iterator i = this.attachments.iterator(); i.hasNext();) {
                    a = (Attachment) i.next();
                    multipart.addBodyPart(a.getBodyPart(resolver, sources));
                }
            }

            message.saveChanges();
            Transport.send(message);
View Full Code Here

                if (!(objRef instanceof Multipart)) {
                    String message = "Message of id " + String.valueOf(msgId) + " is not a multipart message!";
                    getLogger().warn(message);
                    return;
                }
                Multipart multipart = (Multipart) objRef;
                int numParts = multipart.getCount();

                if (partId < numParts) {
                    part = multipart.getBodyPart(partId);
                } else {
                    String message = "Invalid part id " + String.valueOf(this.partId) + " of message id " + String.valueOf(this.msgId);
                    getLogger().warn(message);
                }
                addResult(part);
View Full Code Here

            sm.setText(messageString);
        }
        // add message as message body part
        else {
            messageBodyPart.setContent(messageString, this.bodyMimeType);
            Multipart multipart = new MimeMultipart();
            multipart.addBodyPart(messageBodyPart);

            // process attachments
            Iterator i = this.attachments.iterator();
            while (i.hasNext()) {
                AttachmentDescriptor aD = (AttachmentDescriptor) i.next();
                messageBodyPart = new MimeBodyPart();
   
                if (!aD.isTextContent()) {
                    Source inputSource = resolver.resolveURI(aD.isURLSource() ? aD.strAttrSrc : aD.strAttrFile);
                    this.usedSources.add(inputSource);
   
                    DataSource dataSource = new SourceDataSource(inputSource, aD.strAttrMimeType, aD.strAttrName);

                    messageBodyPart.setDataHandler(new DataHandler(dataSource));
                } else {
                    messageBodyPart.setContent(aD.strContent, aD.strAttrMimeType);
                }
   
                messageBodyPart.setFileName(aD.strAttrName);
                multipart.addBodyPart(messageBodyPart);
            }
            sm.setContent(multipart);
        }

        //sm.setReturnOption(SMTPMessage.RETURN_FULL);
View Full Code Here

                addAttribute("file-name", part.getFileName());
            }
        } else {
            boolean hasAttachments = false;
            if (part.isMimeType("multipart/*")) {
                Multipart mp = (Multipart) part.getContent();
                if (mp.getCount() > 1) {
                    hasAttachments = true;
                    addAttribute("num-parts", String.valueOf(mp.getCount()));
                }
            }
            addAttribute("has-attachments", String.valueOf(hasAttachments));
        }

View Full Code Here

            }
            if (bestPart != null) {
                partToSAX(contentHandler, bestPart, 0);
            }
        } else if (part.isMimeType("multipart/*")) {
            Multipart mp = (Multipart) part.getContent();

            int count = mp.getCount();
            for (int i = 0; i < count; i++) {
                partToSAX(contentHandler, mp.getBodyPart(i), i);
            }
        } else if (part.isMimeType("message/rfc822")) {
            partToSAX(contentHandler, (Part) part.getContent(), 0);
        } else {
            /*
 
View Full Code Here

      IOException, DecoderException {
    StringBuffer content = new StringBuffer("");
    if (p.isMimeType("text/plain")) {
      content.append((String) p.getContent());
    } else if (p.isMimeType("multipart/*")) {
      Multipart mp = (Multipart) p.getContent();
      int count = mp.getCount();
      for (int i = 0; i < count; i++)
        content.append(getContentFromPlainText(mp.getBodyPart(i)));
    } else {
      Object obj = p.getContent();
      if (obj instanceof Part)
        content.append(getContentFromPlainText((Part) p.getContent()));
    }
View Full Code Here

TOP

Related Classes of javax.mail.Multipart

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.