Package javax.mail.internet

Examples of javax.mail.internet.InternetAddress


      Iterator it = toSet.iterator();
      Address[] newTo = new Address[toSet.size()];
      for (int i = 0; it.hasNext(); i++)
      {
         String address = (String)it.next();
         newTo[i] = new InternetAddress(address);
      }
      to = newTo;
   }
View Full Code Here


   }

   public void setFrom(String f) throws AddressException
   {
      fromString = f;
      from = new InternetAddress(f);
   }
View Full Code Here

   }

   public void setReplyTo(String f) throws AddressException
   {
      replyToString = f;
      replyTo = new InternetAddress(f);
   }
View Full Code Here

                  properties.getProperty(
                      "mail.smtp.password", ""));
            }
          });
      MimeMessage message = new MimeMessage(session);
      message.setFrom(new InternetAddress(sender));
      message.setReplyTo(new InternetAddress[] { new InternetAddress(
          sender) });
      message.setRecipients(Message.RecipientType.TO,
          InternetAddress.parse(recipients, false));
      message.setSubject(subject, "utf-8");
      message.setSentDate(new Date());
View Full Code Here

            throw new RuntimeException("This mail sender is stopped");
        }
        try {
            MimeMessage mm = new MimeMessage(getSession());
            mm.setSubject(subject);
            InternetAddress ia;
            if( fromPersonal == null ) {
                ia = new InternetAddress(from);
            } else {
                ia = new InternetAddress(from, fromPersonal);
            }
            mm.setFrom(ia);
            Address[] add = new Address[1];
            add[0] = new InternetAddress(replyTo);
            mm.setReplyTo(add);
            for (String sTo : to) {
                if( sTo != null && sTo.length() > 0 ) {
                    InternetAddress recip = null;
                    try {
                        recip = new InternetAddress(sTo);
                    } catch (AddressException addressException) {
                        throw new RuntimeException("Couldnt parse email address: " + sTo, addressException);
                    }
                    mm.addRecipient(RecipientType.TO, recip);
                }
View Full Code Here

     * if the mailhost was not set in the olat_config.xml, we assume that no
     * emailing is wished.
     */
    if (MailHelper.getMailhost() == null || MailHelper.getMailhost().equals("") || ((MailHelper.getMailhost() instanceof String) && ((String)MailHelper.getMailhost()).equalsIgnoreCase("disabled"))) return false;
    MimeMessage msg = MailHelper.createMessage();
    msg.setFrom(new InternetAddress(this.mailfrom));
    msg.setSubject(subject, "utf-8");
    msg.setText(body + footer, "utf-8");
    msg.setSentDate(new Date());
    Iterator iter = listOfContactLists.iterator();
    while (iter.hasNext()) {
      ContactList tmp = (ContactList) iter.next();
      InternetAddress groupName[] = InternetAddress.parse(tmp.getRFC2822Name() + ";");
      InternetAddress members[] = tmp.getEmailsAsAddresses();
      msg.addRecipients(RecipientType.TO, groupName);
      msg.addRecipients(RecipientType.BCC, members);
    }
    msg.saveChanges();
    MailerResult result = new MailerResult();
View Full Code Here

     * if the mailhost was not set in the olat_config.xml, we assume that no
     * emailing is wished.
     */
    if (MailHelper.getMailhost() == null || MailHelper.getMailhost().equals("") || ((MailHelper.getMailhost() instanceof String) && ((String)MailHelper.getMailhost()).equalsIgnoreCase("disabled"))) return false;
    MimeMessage msg = MailHelper.createMessage();
    msg.setFrom(new InternetAddress(from));
    msg.setRecipients(RecipientType.TO, InternetAddress.parse(mailto));
    msg.setSubject(subject, "utf-8");
    msg.setText(body + footer, "utf-8");
    msg.setSentDate(new Date());
    msg.saveChanges();
View Full Code Here

        .getRecipients(RecipientType.BCC), body + footer, subject, null, result);
    return true;
  }

  static InternetAddress asInternetAddressArray(String address) {
    InternetAddress ia = null;
    try {
      ia = new InternetAddress(address);
    } catch (AddressException ae) {
      throw new RuntimeException("Error in InternetAddress : " + address);
    }
    return ia;
  }
View Full Code Here

 
    // add sender to mail
    Address from, to;
    try {
      if (sender == null) {
        from = new InternetAddress(WebappHelper.getMailConfig("mailFrom"));
      } else {
        from = new InternetAddress(sender.getUser().getProperty(UserConstants.EMAIL, null));
      }
    } catch (AddressException e) {
      result.setReturnCode(MailerResult.SENDER_ADDRESS_ERROR);
      return null;
    }
 
    try {
      to = new InternetAddress(recipientTO.getUser().getProperty(UserConstants.EMAIL, null));
    } catch (AddressException e) {
      result.addFailedIdentites(recipientTO);
      // skip this user, go to next one
      return null;
    }
View Full Code Here

    if (recipients != null && recipients.size() > 0) {
      List<Address> validRecipients = new ArrayList<Address>();
      for (int i = 0; i < recipients.size(); i++) {
        Identity identity = recipients.get(i);
        try {
          validRecipients.add(new InternetAddress(identity.getUser().getProperty(UserConstants.EMAIL, null)));
        } catch (AddressException e) {
          result.addFailedIdentites(identity);
        }
      }
      addresses = validRecipients.toArray(new Address[validRecipients.size()]);
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.