Examples of InternetAddress


Examples of javax.mail.internet.InternetAddress

                           "urn:content-classes:calendarmessage" );
        message.setHeader( "Content-ID",
                           "calendar_message" );

        String creatorEmail = userInfo.getEmailForEntity( creator );
        message.setFrom( new InternetAddress( creatorEmail ) );
        message.setReplyTo( new InternetAddress[]{new InternetAddress( creatorEmail )} );
        message.addRecipient( Message.RecipientType.TO,
                              new InternetAddress( userInfo.getEmailForEntity( owner ) ) );
        message.setSubject( "Task Assignment " + type + " Event: " + name );
        message.setSentDate( new Date() );

        // Create a Multipart
        Multipart multipart = new MimeMultipart( "alternative" );
View Full Code Here

Examples of javax.mail.internet.InternetAddress

    } catch (MessagingException e) {
      log.error("Error Opening transport for sending "+loginLink+" ("+e.toString()+")");
      throw new RuntimeException("Opening Transport", e);
    }
    try {
        InternetAddress address = new InternetAddress(email);

        Message msg = new MimeMessage(session);

        msg.setFrom(new InternetAddress(configuration.getFromAddress()));

        msg.setRecipient(Message.RecipientType.TO, address);
        String title = "GVS Login Link";
        try {
          msg.setSubject(MimeUtility.encodeText(title, "UTF-8", null));
        } catch (UnsupportedEncodingException e) {
          throw new RuntimeException(e);

        }
        msg.setSentDate(new java.util.Date());
        // create and fill the first message part

        MimeBodyPart plainTextVersion = new MimeBodyPart();
        plainTextVersion.setDataHandler(new DataHandler(textDataSource));

        MimeBodyPart htmlPart = new MimeBodyPart();
        htmlPart.setDataHandler(new DataHandler(htmlDataSource));
        // create the Multipart
        // and its parts to it
        Multipart bodyAlternatives = new MimeMultipart("alternative");
        bodyAlternatives.addBodyPart(plainTextVersion);
        htmlPart.setHeader("Content-Type", "text/html; charset=UTF-8");
        bodyAlternatives.addBodyPart(htmlPart);



        // mbp1.setHeader("Content-Language", "fr");
        // add the Multipart to the message
        Multipart mainMultipart = new MimeMultipart();
        BodyPart body = new MimeBodyPart();
        body.setContent(bodyAlternatives);
        mainMultipart.addBodyPart(body);

        // mainMultipart.addBodyPart(getSerialializerRDFPart(mailModel));

        msg.setContent(mainMultipart);
        log.debug("mesage ready, sending");
        Transport.send(msg);
        /*
         * Reusing conncection: (problem:isp limits) Address[] recipients = new
         * Address[1]; recipients[0] = recipient; transport.sendMessage(msg,
         * recipients);
         */
        log.info("message sent to " + address.getAddress() + " ("
            + Thread.activeCount() + ")");
      } catch (Exception ex) {
        log.error("sending email: ", ex);
      }
    try {
View Full Code Here

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

Examples of javax.mail.internet.InternetAddress

      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

Examples of javax.mail.internet.InternetAddress

      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

Examples of javax.mail.internet.InternetAddress

      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

Examples of javax.mail.internet.InternetAddress

        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

Examples of javax.mail.internet.InternetAddress

      //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

Examples of javax.mail.internet.InternetAddress

            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

Examples of javax.mail.internet.InternetAddress

     * @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
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.