Examples of InternetAddress


Examples of javax.mail.internet.InternetAddress

   }

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

Examples of javax.mail.internet.InternetAddress

   }

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

Examples of javax.mail.internet.InternetAddress

   public void sendEmail(String from, String to, String subject, String body)
         throws AddressException, MessagingException {
      Message message = getMessage();
      try {
         message.setFrom(new InternetAddress(from));
         InternetAddress tos[] = new InternetAddress[1];
         tos[0] = new InternetAddress(to);
         message.setRecipients(Message.RecipientType.TO, tos);
         message.setSubject(subject);
         message.setContent(body, "text/plain");
      } catch (MessagingException e) {
         throw e;
View Full Code Here

Examples of javax.mail.internet.InternetAddress

      send(message);
   }

   public void sendEmail(String from, String to, String subject, String body,
         String encoding) throws AddressException, MessagingException {
      sendEmail(new InternetAddress(from), new InternetAddress(to), subject,
            body, encoding);
   }
View Full Code Here

Examples of javax.mail.internet.InternetAddress

         String subject, String body, String encoding) throws AddressException,
         MessagingException {
      MimeMessage message = new MimeMessage(getSession());
      try {
         message.setFrom(from);
         InternetAddress tos[] = new InternetAddress[1];
         tos[0] = to;
         message.setRecipients(Message.RecipientType.TO, tos);
         message.setSubject(subject, encoding);
         message.setText(body, encoding); // is automatically "text/plain"
      } catch (MessagingException e) {
View Full Code Here

Examples of javax.mail.internet.InternetAddress

         String attachmentName2, String attachment2, String encoding)
         throws XmlBlasterException {
      try {
         MimeMessage message = new MimeMessage(getSession());
         message.setFrom(from);
         InternetAddress tos[] = new InternetAddress[1];
         tos[0] = to;
         message.setRecipients(Message.RecipientType.TO, tos);
         message.setSubject(subject, encoding);

         // MimeBodyPart mbp1 = new MimeBodyPart(attachment);
View Full Code Here

Examples of javax.mail.internet.InternetAddress

      this.content = null;
   }
  
   private InternetAddress toInternetAddress(String address) throws IllegalArgumentException {
      try {
         return new InternetAddress(address);
      } catch (AddressException e) {
         throw new IllegalArgumentException("Illegal email address '" + address + "': " + e.toString());
      }
   }
View Full Code Here

Examples of javax.mail.internet.InternetAddress

      // TO
      if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
         for (int j = 0; j < a.length; j++) {
            pr("TO: " + a[j].toString(), level);
            InternetAddress ia = (InternetAddress) a[j];
            if (ia.isGroup()) {
               InternetAddress[] aa = ia.getGroup(false);
               for (int k = 0; k < aa.length; k++)
                  pr("  GROUP: " + aa[k].toString(), level);
            }
         }
      }
View Full Code Here

Examples of javax.mail.internet.InternetAddress

   * @throws NullPointerException
   * @throws UnsupportedEncodingException
   */
  public static InternetAddress parseAddress(String sNamePlusEMail)
    throws AddressException,NullPointerException,UnsupportedEncodingException {
    InternetAddress oRetAdr = null;

    String sAddr = sNamePlusEMail.trim();

    int iLeftAng = sAddr.indexOf('<');
    int iRightAng= sAddr.indexOf('>');
    int iLeftPar = sAddr.indexOf('(');
    int iRightPar= sAddr.indexOf(')');
    int iLeftQuo = sAddr.indexOf('"');
    int iRightQuo;
    if (iLeftQuo>=0) iRightQuo = sAddr.indexOf('"',iLeftQuo+1); else iRightQuo = -1;

    if (iRightAng<iLeftAng) throw new AddressException("Misplaced right angle");
    if (iLeftAng<0 && iRightAng>=0) throw new AddressException("Missing left angle");
    if (iLeftAng>=0 && iRightAng<0) throw new AddressException("Missing right angle");
    if (iLeftPar<0 && iRightPar>=0) throw new AddressException("Missing left parenthesis");
    if (iLeftPar>=0 && iRightPar<0) throw new AddressException("Missing right parenthesis");
    if (iRightPar<iLeftPar) throw new AddressException("Misplaced right parenthesis");
    if (iLeftQuo>=0 && iRightQuo<0) throw new AddressException("Unclosed quote");

    if (iLeftAng>=0 && iRightAng>=0 && iLeftPar>=0 && iRightPar>=0) {
      // Address is (Name) <user@domain.com> or <user@domain.com> (Name)
      oRetAdr = new InternetAddress(sAddr.substring(iLeftAng+1,iRightAng),sAddr.substring(iLeftPar+1,iRightPar));
    } else if (iLeftAng>=0 && iRightAng>=0 && iLeftQuo>=0 && iRightQuo>=0) {
      // Address is "Name" <user@domain.com> or "Name" <user@domain.com>
      oRetAdr = new InternetAddress(sAddr.substring(iLeftAng+1,iRightAng),sAddr.substring(iLeftQuo+1,iRightQuo));
    } else if (iLeftAng>=0 && iRightAng>=0) {
      // Address is Name <user@domain.com> or <user@domain.com> Name
      if (0==iLeftAng)
        oRetAdr = new InternetAddress(sAddr.substring(1,iRightAng),sAddr.substring(iRightAng+1));
      else
        oRetAdr = new InternetAddress(sAddr.substring(iLeftAng+1,iRightAng),sAddr.substring(0,iLeftAng));
    } else {
      oRetAdr = new InternetAddress(sAddr);
    }
    return oRetAdr;
  }
View Full Code Here

Examples of javax.mail.internet.InternetAddress

   * Join mail addresses array on a single String
   * @param aRecipients Address[]
   * @return String Mail addresses delimited by semicolons
   */
  public static String joinAddressList (Address[] aRecipients) {
    InternetAddress oInetAdr;
    String sList = "";
    if (DebugFile.trace) {
      DebugFile.writeln("Begin RecipientsHelper.joinAddressList(Address[])");
      DebugFile.incIdent();
    }
    if (aRecipients!=null) {
      int cRecipients = aRecipients.length;
      if (cRecipients>0) {
        for (int a=0; a<cRecipients; a++) {
          oInetAdr = (InternetAddress) aRecipients[a];
          if (0!=a) sList += ";";
          sList += oInetAdr.getAddress();
        } // next
      } // fi (cRecipients>0)
    } // fi (aRecipients)
    if (DebugFile.trace) {
      DebugFile.writeln("End RecipientsHelper.joinAddressList() : " + sList);
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.