Package javax.mail.internet

Examples of javax.mail.internet.MimeMultipart$MimeBodyPartInputStream


    if (bccStr != null && !bccStr.equals("")) {
      sendMsg.setHeader("Bcc",bccStr);
    }

    if (sendMultipart == null) {
      sendMultipart = new MimeMultipart();
    }

    tmpBodyPart = new MimeBodyPart();

    if (msgBody != null) {
View Full Code Here


    debug(hr);

    /* Check to see if we need to create a new MimeMultipart */

    if (sendMultipart == null) {
      sendMultipart = new MimeMultipart();
    }

    /* Collect our parameter values */

    partData = hr.get("body");
View Full Code Here

     */
    @Converter
    public static String toString(Message message) throws MessagingException, IOException {
        Object content = message.getContent();
        if (content instanceof MimeMultipart) {
            MimeMultipart multipart = (MimeMultipart) content;
            if (multipart.getCount() > 0) {
                BodyPart part = multipart.getBodyPart(0);
                content = part.getContent();
            }
        }
        if (content != null) {
            return content.toString();
View Full Code Here

    Properties props = new Properties();
    Session mailSession = Session.getInstance(props, null);
        String msgBody = "Click" + "<a href='http://stewiemaze.appspot.com/register-player.do/validate.do?nickname=" + nickname +"'>" +
            " Here</a> to validate you account";
        Message msg = new MimeMessage(mailSession);
        Multipart mp = new MimeMultipart();
        MimeBodyPart htmlPart = new MimeBodyPart();
        htmlPart.setContent(msgBody, "text/html");
        mp.addBodyPart(htmlPart);
        msg.setContent(mp);
        msg.setFrom(new InternetAddress("admin@stewiemaze.appspotmail.com"));
        msg.addRecipient(Message.RecipientType.TO,
                         new InternetAddress(email, nickname));
        msg.setSubject("Account Activation");
View Full Code Here

      // set Subject to the message
      mimeMessage.setSubject(subject);
      mimeMessage.setSubject(message.getSubject(), "UTF-8");
      mimeMessage.setSentDate(new Date());

      MimeMultipart multipPartRoot = new MimeMultipart("mixed");

      MimeMultipart multipPartContent = new MimeMultipart("alternative");

      if (attachment != null && attachment.size() != 0)
      {
         MimeBodyPart contentPartRoot = new MimeBodyPart();
         if (mimeType != null && mimeType.indexOf("text/plain") > -1)
            contentPartRoot.setContent(body, "text/plain; charset=utf-8");
         else
            contentPartRoot.setContent(body, "text/html; charset=utf-8");
         MimeBodyPart mimeBodyPart1 = new MimeBodyPart();
         mimeBodyPart1.setContent(body, mimeType);
         multipPartContent.addBodyPart(mimeBodyPart1);
         multipPartRoot.addBodyPart(contentPartRoot);
         for (Attachment att : attachment)
         {
            InputStream is = att.getInputStream();
            MimeBodyPart mimeBodyPart = new MimeBodyPart();
View Full Code Here

      // set Subject to the message
      mimeMessage.setSubject(subject);
      mimeMessage.setSubject(message.getSubject(), "UTF-8");
      mimeMessage.setSentDate(new Date());

      MimeMultipart multipPartRoot = new MimeMultipart("mixed");

      MimeMultipart multipPartContent = new MimeMultipart("alternative");

      if (attachment != null && attachment.size() != 0)
      {
         MimeBodyPart contentPartRoot = new MimeBodyPart();
         if (mimeType != null && mimeType.indexOf("text/plain") > -1)
            contentPartRoot.setContent(body, "text/plain; charset=utf-8");
         else
            contentPartRoot.setContent(body, "text/html; charset=utf-8");
         MimeBodyPart mimeBodyPart1 = new MimeBodyPart();
         mimeBodyPart1.setContent(body, mimeType);
         multipPartContent.addBodyPart(mimeBodyPart1);
         multipPartRoot.addBodyPart(contentPartRoot);
         for (Attachment att : attachment)
         {
            InputStream is = att.getInputStream();
            MimeBodyPart mimeBodyPart = new MimeBodyPart();
View Full Code Here

      protected WSRPMultiRequestContext(String characterEncoding, List<NamedString> formParams, List<UploadContext> uploadContexts) throws IOException, MessagingException
      {
         super(characterEncoding);

         MimeMultipart parts = new MimeMultipart();
         if (uploadContexts != null && !uploadContexts.isEmpty())
         {
            for (UploadContext uploadContext : uploadContexts)
            {
               InternetHeaders headers = new InternetHeaders();
               headers.addHeader(FileUpload.CONTENT_TYPE, uploadContext.getMimeType());

               List<NamedString> attributes = uploadContext.getMimeAttributes();
               if (attributes != null && !attributes.isEmpty())
               {
                  for (NamedString attribute : attributes)
                  {
                     headers.addHeader(attribute.getName(), attribute.getValue());
                  }
               }

               MimeBodyPart mimeBodyPart = new MimeBodyPart(headers, uploadContext.getUploadData());
               parts.addBodyPart(mimeBodyPart);
            }
         }

         final String paramContentDispositionHeader = FileUpload.FORM_DATA + "; name=\"";
         if (formParams != null && !formParams.isEmpty())
         {
            Map<String, String[]> params = new HashMap<String, String[]>(formParams.size());
            for (NamedString formParam : formParams)
            {
               InternetHeaders headers = new InternetHeaders();

               headers.addHeader(FileUpload.CONTENT_DISPOSITION, paramContentDispositionHeader + formParam.getName() + "\"");

               MimeBodyPart mimeBodyPart = new MimeBodyPart(headers, formParam.getValue().getBytes());
               parts.addBodyPart(mimeBodyPart);
              
              
               String paramName = formParam.getName();
               String paramValue = formParam.getValue();
               if (params.containsKey(paramName))
               {
                  // handle multi-valued parameters...
                  String[] oldValues = params.get(paramName);
                  int valuesLength = oldValues.length;
                  String[] newValues = new String[valuesLength + 1];
                  System.arraycopy(oldValues, 0, newValues, 0, valuesLength);
                  newValues[valuesLength] = paramValue;
                  params.put(paramName, newValues);
               }
               else
               {
                  params.put(paramName, new String[]{paramValue});
               }
            }
            formParameters = new ParameterMap(params);
         }

         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         parts.writeTo(baos);
         content = baos.toByteArray();
         contentType = parts.getContentType();
      }
View Full Code Here

   */
  public void send(String fromAddress, String[] toEmailAddresses,
      String[] ccEmailAddresses, String subject, String content)
      throws MessagingException {
    MimeMessage message = new MimeMessage(session);
    MimeMultipart multipart = new MimeMultipart();
    message.setSubject(subject);
    message.setRecipients(Message.RecipientType.TO,
        emailToInternetAddressArray(toEmailAddresses));
    message.setRecipients(Message.RecipientType.CC,
        emailToInternetAddressArray(ccEmailAddresses));
    message.addFrom(InternetAddress.parse(fromAddress));
    message.setSentDate(new Date());
    BodyPart mainBody = new MimeBodyPart();
    mainBody.setContent(content, "text/html;charset=gbk");
    multipart.addBodyPart(mainBody);
    for (Entry<String, String> e : mailAttachment.entrySet()) {
      BodyPart bodyPart = new MimeBodyPart();
      bodyPart.setDataHandler(new DataHandler(new FileDataSource(e
          .getKey())));
      bodyPart.setFileName(e.getValue());
      bodyPart.setHeader("Content-ID", e.getValue());
      multipart.addBodyPart(bodyPart);
    }
    message.setContent(multipart);
    message.saveChanges();
    Transport.send(message, message.getAllRecipients());
    Misc.getLogger().info("Send Mail success!");
View Full Code Here

   */
  public void send(String fromAddress, String[] toEmailAddresses,
      String[] ccEmailAddresses, String subject, String content)
      throws MessagingException {
    MimeMessage message = new MimeMessage(session);
    MimeMultipart multipart = new MimeMultipart();
    message.setSubject(subject);
    message.setRecipients(Message.RecipientType.TO,
        emailToInternetAddressArray(toEmailAddresses));
    message.setRecipients(Message.RecipientType.CC,
        emailToInternetAddressArray(ccEmailAddresses));
    message.addFrom(InternetAddress.parse(fromAddress));
    message.setSentDate(new Date());
    BodyPart mainBody = new MimeBodyPart();
    mainBody.setContent(content, "text/html;charset=gbk");
    multipart.addBodyPart(mainBody);
    for (Entry<String, String> e : mailAttachment.entrySet()) {
      BodyPart bodyPart = new MimeBodyPart();
      bodyPart.setDataHandler(new DataHandler(new FileDataSource(e
          .getKey())));
      bodyPart.setFileName(e.getValue());
      bodyPart.setHeader("Content-ID", e.getValue());
      multipart.addBodyPart(bodyPart);
    }
    message.setContent(multipart);
    message.saveChanges();
    Transport.send(message, message.getAllRecipients());
  }
View Full Code Here

        super.startElement(namespace, localName, prefix, attributes, context);

        if (getValue() instanceof DataHandler) {
            try {
                DataHandler dh = (DataHandler) getValue();
                MimeMultipart mmp = new MimeMultipart(dh.getDataSource());
                if (mmp.getCount() == 0) {
                    mmp = null;
                }
                setValue(mmp);
            }
            catch (Exception e) {
View Full Code Here

TOP

Related Classes of javax.mail.internet.MimeMultipart$MimeBodyPartInputStream

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.