Package javax.mail.internet

Examples of javax.mail.internet.InternetAddress


              if (row != null) {
                // check the RecipientType and add to the proper list
                if (((String)row.get("RecipientType")).equals("TO")) {
                  // To: address
                  try{
                    toList.add(new InternetAddress((String)row.get("Address")));
                  } catch (AddressException ae) {
                    toList.add(row.get("Address"));
                  }
                }else if (((String)row.get("RecipientType")).equals("CC")){
                  // Cc: address
                  try{
                    ccList.add(new InternetAddress((String)row.get("Address")));
                  }catch(AddressException ae){
                    ccList.add(row.get("Address"));
                  }
                }else if (((String)row.get("RecipientType")).equals("BCC")){
                  // Bcc: address
                  try{
                    bccList.add(new InternetAddress((String)row.get("Address")));
                  }catch(AddressException ae){
                    bccList.add(row.get("Address"));
                  }
                }
              }
View Full Code Here


      Address[] toRecipients = new Address[toList.size()];
      Iterator toIter = toList.iterator();
      int count = 0;
      while (toIter.hasNext()) {
        String address = (String)toIter.next();
        toRecipients[count] = (Address)(new InternetAddress(address));
        count++;
      }
     
      this.addRecipients(toRecipients, messageID, "TO", cvdal);
     
      ArrayList ccList = (ArrayList)messageVO.getCcList();
      Address[] ccRecipients = new Address[ccList.size()];
      Iterator ccIter = ccList.iterator();
      count = 0;
      while (ccIter.hasNext()) {
        String address = (String)ccIter.next();
        ccRecipients[count] = (Address)(new InternetAddress(address));
        count++;
      }
     
      this.addRecipients(ccRecipients, messageID, "CC", cvdal);
     
      ArrayList bccList = (ArrayList)messageVO.getBccList();
      Address[] bccRecipients = new Address[bccList.size()];
      Iterator bccIter = bccList.iterator();
      count = 0;
      while (bccIter.hasNext()) {
        String address = (String)bccIter.next();
        bccRecipients[count] = (Address)(new InternetAddress(address));
        count++;
      }
      this.addRecipients(bccRecipients, messageID, "BCC", cvdal);
    }catch(Exception e){
      System.out.println("[Exception][MailEJB] Exception thrown in saveDraft(int,MailMessageVO): " + e);
View Full Code Here

      message.addRecipients(Message.RecipientType.TO, arrayTo);
      message.addRecipients(Message.RecipientType.CC, arrayCc);
      message.addRecipients(Message.RecipientType.BCC, arrayBcc);

      message.setFrom(new InternetAddress(fromAddress));
      // So we don't require a Reply-To address
      if (replyToAddress != null && replyToAddress.length() != 0) {
        message.setReplyTo(new Address[] {new InternetAddress(replyToAddress)});
      }
      //Add raw headers to message object
      StringTokenizer tokenizer = new StringTokenizer(headers, System.getProperty("line.separator", "\n"));
      while (tokenizer.hasMoreTokens()) {
        message.addHeaderLine(tokenizer.nextToken());
View Full Code Here

      Iterator addressIterator = addressCollection.iterator();
      int count = 0;

      while (addressIterator.hasNext()) {
        Address address  = new InternetAddress((String) addressIterator.next());
        addressArray[count++] = address;
      }
    }   // end if (addressCollection != null)

    return addressArray;
View Full Code Here

        int messageID = ((Integer) messageIDs.get(i)).intValue();
        if (messageID != -1) {
          MailMessageVO mailMessageVO = this.getEmailMessageVO(ownerID, messageID);
          String messageFrom = mailMessageVO.getFromAddress();

          InternetAddress emailAddress = new InternetAddress(messageFrom);
          messageFrom = emailAddress.getAddress();

          String messageSubject = mailMessageVO.getSubject();
          String messageBody = mailMessageVO.getBody();
          Html2Text plainMessageBody = new Html2Text(messageBody);

          int accountID = mailMessageVO.getEmailAccountID();
          int ticketID = 0;

          int startIndex = messageSubject.indexOf("TICKET#");
          int endIndex = -1;
          if (startIndex >0) {
            endIndex = messageSubject.indexOf("#",(startIndex + 7));
          }

          if (startIndex >0 && endIndex > startIndex) {
            startIndex = startIndex + 7;
            String tempTicketID =messageSubject.substring(startIndex,endIndex);
            if (tempTicketID != null && !tempTicketID.equals("")) {
              ticketID = Integer.parseInt(tempTicketID);
            }
          }

          if (ticketID == 0) {
            TicketVO ticketVO = new TicketVO();
            ticketVO.setTitle(messageSubject);
            ticketVO.setDetail(plainMessageBody.getPlainText());
            ticketVO.setPriorityId(1);
            ticketVO.setStatusId(1);
            ticketVO.setCreatedBy(ownerID);

            HashMap contactInfo = contactHelperRemote.getContactInfoForEmailAddress(messageFrom);

            int assignedId = 0;
            int entityId = 0;
            int individualId = 0;

            if (strAssignedID != null && !strAssignedID.equals("")) {
              try {
                assignedId = Integer.parseInt(strAssignedID);
              } catch(NumberFormatException nfe){
                // already set a default value
              }
            }

            if (contactInfo != null && contactInfo.size() != 0) {
              entityId = ((Number) contactInfo.get("EntityID")).intValue();
              individualId = ((Number) contactInfo.get("IndividualID")).intValue();
            }else{
              // initialize thread vo
              ThreadVO tVO = new ThreadVO();
              tVO.setTitle(messageFrom+": "+messageSubject);
              tVO.setDetail("");
              tVO.setPriorityId(1);
              tVO.setCreatedBy(ownerID);
              tVO.setOwner(ownerID);

              ticketVO.setThreadVO(tVO);
            } // end of else if (contactInfo != null && contactInfo.size() != 0)

            ticketVO.setAssignedToId(assignedId);
            ticketVO.setRefEntityId(entityId);
            ticketVO.setRefIndividualId(individualId);

            defaultMessageBody = ticketTemplateForm.getBody();
            String ticketSubject = ticketTemplateForm.getSubject();

            try {
              ticketID = ticketRemote.addTicket(ownerID, ticketVO);
            }catch(Exception e){
              defaultMessageBody = errorTemplateForm.getBody();
            }// end of catch block

            messageSubject = ticketSubject+"-["+messageSubject+"] TICKET#"+ticketID+"#";
            int arrBlank[] = {};
            authRemote.saveRecordPermission(ownerID,-1,"Ticket",ticketID,arrBlank,arrBlank,arrBlank);
          }else{
            // initialize thread vo
            ThreadVO tVO = new ThreadVO();
            tVO.setTitle(messageSubject);
            tVO.setDetail(plainMessageBody.getPlainText());
            tVO.setTicketId(ticketID);
            tVO.setPriorityId(1);
            tVO.setCreatedBy(ownerID);
            tVO.setOwner(ownerID);

            defaultMessageBody = threadTemplateForm.getBody();

            try {
              ticketRemote.addThread(ownerID, tVO);
            }catch(Exception e){
              defaultMessageBody = errorTemplateForm.getBody();
            }// end of catch block

            messageSubject = "RE: "+messageSubject;
          }// end of else for if (ticketID == 0)

          // create a MailMessageVO
          MailMessageVO messageVO = new MailMessageVO();
          messageVO.setEmailAccountID(accountID);

          MailAccountVO accountVO = this.getMailAccountVO(accountID);
          if (accountVO == null) {
            accountVO = new MailAccountVO();
          }

          InternetAddress fromAddress = new InternetAddress(accountVO.getEmailAddress(), accountVO.getAccountName());
          messageVO.setFromAddress(fromAddress.toString());
          messageVO.setReplyTo(accountVO.getReplyToAddress());

          ArrayList toList = new ArrayList();
          toList.add(messageFrom);
          messageVO.setToList(toList);
View Full Code Here

      //if you don't specify the from email address we will enter the administrator email address
      if(fromAddress == null){
        fromAddress =  adminEmailAddress;
      }
      message.setFrom(new InternetAddress(fromAddress));

      if (replyToAddress != null && !replyToAddress.equals("")){
        message.setReplyTo(new Address[] {new InternetAddress(replyToAddress)});
      }

      //Add raw headers to message object
      StringTokenizer tokenizer = new StringTokenizer(headers, System.getProperty("line.separator", "\n"));
      while (tokenizer.hasMoreTokens()) {
View Full Code Here

            session.setDebug( debug );
           
            // construct the message
            Message msg = new MimeMessage( session );
           
            msg.setFrom( new InternetAddress( from ) );
            msg.setReplyTo( new InternetAddress[] {  new InternetAddress( replyTo ) }  );
           
            for ( Recipient recipient : message.getRecipients().getRecipients() ) {
                RecipientType type = null;
                if ( "To".equals( recipient.getType() ) ) {
                    type = Message.RecipientType.TO;
View Full Code Here

     * @throws MessagingException
     * @throws UnsupportedEncodingException
     */
    public void setMailFrom(String mailFrom, String sender) throws UnsupportedEncodingException, MessagingException {
      if(sender!=null)
        mailMessage.setFrom(new InternetAddress(mailFrom, sender));
      else
        mailMessage.setFrom(new InternetAddress(mailFrom));
    }
View Full Code Here

     * @param mailType ֵΪto,cc,bcc
     * @author Liudong
     */
    public void setMailTo(String[] mailTo, String mailType) throws Exception {
        for (int i = 0; i < mailTo.length; i++) {
            mailToAddress = new InternetAddress(mailTo[i]);
            if (mailType.equalsIgnoreCase("to")) {
                mailMessage.addRecipient(Message.RecipientType.TO,mailToAddress);
            } else if (mailType.equalsIgnoreCase("cc")) {
                mailMessage.addRecipient(Message.RecipientType.CC,mailToAddress);
            } else if (mailType.equalsIgnoreCase("bcc")) {
View Full Code Here

  protected InternetAddress getAddress(String addressStr)
  {
    try
    {
      return new InternetAddress(addressStr);
    }
    catch (AddressException e)
    {
      reportError("Could not parse address [" + addressStr + "].",
        e,
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.