Package javax.mail.internet

Examples of javax.mail.internet.InternetAddress


      MailAccountVO accountVO = remote.getMailAccountVO(accountID);
      if (accountVO == null) {
        accountVO = new MailAccountVO();
      }
      if (accountVO.getAccountID() != -1) {
        InternetAddress fromAddress = new InternetAddress(accountVO.getEmailAddress(), accountVO.getAccountName());
        messageVO.setFromAddress(fromAddress.toString());
        messageVO.setReplyTo(fromAddress.toString());
        messageVO.setSubject(subject);
        messageVO.setHeaders("");
        messageVO.setContentType(MailMessageVO.HTML_TEXT_TYPE);
        messageVO.setReceivedDate(new java.util.Date());
        if (content != null && content.size() != 0) {
View Full Code Here


      String replyTo = mailmessage.getReplyTo();

      if (replyTo != null && replyTo.length() >0)
      {
        InternetAddress[] ia = new InternetAddress[1];
        ia[0] = new InternetAddress(replyTo);
        message.setReplyTo(ia);
      }

      if (arrayto.length != 0)
      {
        for (int i = 0; i < arrayto.length; i++)
        {
          message.addRecipient(Message.RecipientType.TO, new InternetAddress(arrayto[i]));
        }
      }

      message.setFrom(new InternetAddress(from));
      message.setSubject(subject);
      BodyPart messageBodyPart        = new MimeBodyPart();
      String messageContext = "text/plain";
      messageBodyPart.setContent(body, messageContext);
      Multipart multipart             = new MimeMultipart();
View Full Code Here

              String replyTo                     = mailmessage.getReplyTo();

              if(replyTo != null && replyTo.length() >0)
              {
                    InternetAddress[] ia = new InternetAddress[1];
                    ia[0] = new InternetAddress(replyTo);
                    message.setReplyTo(ia);
              }

          //  extra headers that may be used for some action in to CV
          // eg - Activity send email, Adding individual throough email
          HashMap hhm                     = mailmessage.getHeadersHM();
          String allHeaderString          = null;
          if (hhm != null)
          {
            allHeaderString = new String();
            Iterator it  = hhm.keySet().iterator();
            while (it.hasNext())
            {
              String hmKey    = (String) it.next();
              String hmValue  = (String) hhm.get(hmKey);
              allHeaderString = allHeaderString.concat(hmKey + "=" + hmValue + "::");
   //           message.addHeader(hmKey, hmValue);

            }
          }
          message.addHeader("X-centraviewID", "" + messageid);

          if (arrayto.length != 0)
          {
            for (int i = 0; i < arrayto.length; i++)
            {
              message.addRecipient(Message.RecipientType.TO, new InternetAddress(arrayto[i]));
            }
          }

          message.setFrom(new InternetAddress(from));
          message.setSubject(subject);
          BodyPart messageBodyPart        = new MimeBodyPart();
          String messageContext = "text/plain";
          messageBodyPart.setContent(body, messageContext);
          Multipart multipart             = new MimeMultipart();
View Full Code Here

          continue;
        }

        if (name == null)
        {
          message.addRecipient(parseType(type), new InternetAddress(address, true));
        }
        else
        {
          try
          {
            message.addRecipient(parseType(type), new InternetAddress(address, name, "UTF-8"));
          }
          catch (UnsupportedEncodingException e)
          {
            // Should not happen - UTF-8 is safe to use
            throw new MessagingException("Failed to encode recipient", e);
View Full Code Here

    }
    msg.setSentDate(new Date());
    if (subject != null) {
      msg.setSubject(subject, charset);
    }
    msg.setFrom(new InternetAddress(from));

    if (attachments == null || attachments.size() == 0) {
      msg.setText(body, charset);

    } else {
View Full Code Here

      int amountAddresses = addressList.size();
      toAddresses = new Address[amountAddresses];
      for (int k = 0; k < amountAddresses; k++)
      {
        toAddresses[k] = new InternetAddress((String) addressList
            .elementAt(k));
      }

      String fromAddressString = config.getValue(
          Constants.CHAPTER_SYSTEM, mDestination.getName(),
          "FromAddress");
      String fromName = config.getValueOptional(Constants.CHAPTER_SYSTEM,
          mDestination.getName(), "FromName");
      if (fromName != null)
      {
        fromAddress = new InternetAddress(fromAddressString, fromName);
      }
      else
      {
        fromAddress = new InternetAddress(fromAddressString);
      }
    }
    catch (Exception e)
    {
      throw new XException(Constants.LOCATION_EXTERN,
View Full Code Here

            try {
              String sUniqueId = sId+"."+String.valueOf(r+1);
              oMap.remove("Message.id");
              oMap.put("Message.id", sUniqueId);             
              SMTPMessage oCurrentMsg = composeMessage(sSubject, sEncoding, oRpl.replace(oTextBody, oMap), oRpl.replace(oHtmlBody, oMap), sUniqueId, aAttachmentsPath, sUserDir);
              oCurrentMsg.setFrom(new InternetAddress(sFromAddr, null==sFromPersonal ? sFromAddr : sFromPersonal));
              if (null!=sReplyAddr) oCurrentMsg.setReplyTo(new Address[]{new InternetAddress(sReplyAddr)});
              if (DebugFile.trace) DebugFile.writeln("SMTPMessage.setRecipient("+aRecType[r]+","+sRecipientAddr+")");
              oCurrentMsg.setRecipient(aRecType[r], new InternetAddress(sRecipientAddr));     
              sendMessage(oCurrentMsg);
              oOut.println("OK "+sRecipientAddr);
              nSend++;
            } catch (Exception xcpt) {
              if (oOut==null) {
                if (DebugFile.trace) DebugFile.writeln("ERROR "+aRecipients[r]+" "+xcpt.getClass().getName()+" "+xcpt.getMessage());
              } else {
                oOut.println("ERROR at SessionHandler.sendMessage() "+aRecipients[r]+" "+xcpt.getClass().getName()+" "+xcpt.getMessage());
              } // fi (oOut)
            }
          } // fi (sRecipientAddr!="")
        } // next     
    } else {
        for (int r=0; r<nRecipients; r++) {
          String sRecipientAddr = Gadgets.removeChars(aRecipients[r], " \t\r\n");
          if (sRecipientAddr.length()>0) {
            SMTPMessage oMasterMsg = composeMessage(sSubject, sEncoding, sTextBody, sHtmlBody, null, aAttachmentsPath, sUserDir);
            oMasterMsg.setFrom(new InternetAddress(sFromAddr, null==sFromPersonal ? sFromAddr : sFromPersonal));
            if (null!=sReplyAddr) oMasterMsg.setReplyTo(new Address[]{new InternetAddress(sReplyAddr)});
            try {
              if (DebugFile.trace) DebugFile.writeln("new SMTPMessage()");
              SMTPMessage oCurrentMsg = new SMTPMessage (oMasterMsg);
              if (DebugFile.trace) DebugFile.writeln("SMTPMessage.setContentID("+sId+"."+String.valueOf(r+1)+")");
              oCurrentMsg.setContentID(sId+"."+String.valueOf(r+1));
              if (DebugFile.trace) DebugFile.writeln("SMTPMessage.setRecipient("+aRecType[r]+","+sRecipientAddr+")");
              oCurrentMsg.setRecipient(aRecType[r], new InternetAddress(sRecipientAddr));     
              sendMessage(oCurrentMsg);
              oOut.println("OK "+sRecipientAddr);
              nSend++;
            }
            catch (Exception xcpt) {
View Full Code Here

     
      // The real message blob, for example "xmlBlasterMessage.xbf"
      String payloadFileName = this.payloadFileNamePrefix +
         msgInfo.getMsgInfoParser(getMsgInfoParserClassName(), pluginConfig).getExtension(isCompressed);

      InternetAddress toAddr = this.toAddress;
      String to = (String)msgInfo.getBounceObject(BOUNCE_MAILTO_KEY);
      if (to != null) {
         try { // The EmailDriver has different destinations for each client
            toAddr = new InternetAddress(to);
         } catch (AddressException e) {
            log.warning("Illegal 'to' address '" + to + "'");
         }
      }
      if (toAddr == null) {
         Thread.dumpStack();
         throw new IllegalArgumentException("No 'toAddress' email address is given, can't send mail: " + MsgInfo.toLiteral(msgInfo.createRawMsg(getMsgInfoParserClassName())));
      }

      EmailData emailData = new EmailData(toAddr, this.fromAddress, subject);
      emailData.setCc(this.cc);
      emailData.setBcc(this.bcc);
      emailData.setExpiryTime(expiryTimestamp);
      String payloadMimetype = msgInfo.getMsgInfoParser(getMsgInfoParserClassName(), pluginConfig).getMimetype(isCompressed);
      emailData.addAttachment(new AttachmentHolder(payloadFileName, payloadMimetype, payload));
      emailData.addAttachment(new AttachmentHolder(this.messageIdFileName, messageId));
      // Bounce all other attachments back to sender
      AttachmentHolder[] attachments = msgInfo.getBounceAttachments();
      for (int i=0; i<attachments.length; i++) {
         AttachmentHolder a = attachments[i];
         if (this.messageIdFileName.equals(a.getFileName()))
            continue; // added alread, see above
         emailData.addAttachment(a);
      }
     
      getSmtpClient().sendEmail(emailData, messageIdFileName);
      //this.smtpClient.sendEmail(this.fromAddress, toAddr, subject,
      //      attachmentName, attachment, attachmentName2, messageId,
      //      Constants.UTF8_ENCODING);

      if (log.isLoggable(Level.FINE)) log.fine("Sending email from="
            + this.fromAddress.toString() + " to=" + toAddr.toString()
            + " messageId=" + messageId
            + " done");
      if (log.isLoggable(Level.FINEST)) log.finest("MsgInfo dump: " + MsgInfo.toLiteral(msgInfo.createRawMsg(getMsgInfoParserClassName())));
   }
View Full Code Here

   }

   /** JMX */
   public void setTo(String to) throws IllegalArgumentException {
      try {
         this.toAddress = new InternetAddress(to);
      } catch (AddressException e) {
         throw new IllegalArgumentException(
               ME + " Illegal 'to' address '" + to + "'");
      }
   }
View Full Code Here

   }

   /** JMX */
   public void setFrom(String from) throws IllegalArgumentException {
      try {
         this.fromAddress = new InternetAddress(from);
      } catch (AddressException e) {
         throw new IllegalArgumentException(
               ME + " Illegal 'from' address '" + from + "'");
      }
   }
View Full Code Here

TOP

Related Classes of javax.mail.internet.InternetAddress

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.