static public MailRecipient parseString(String value){ String[] components = value.split("\\|"); if( components.length > 1 ){ return new MailRecipient( components[0].trim(), components[1].trim() ); } return new MailRecipient(components[0].trim()); }
public void setMailProperties(Properties mailProperties) throws Exception { this.mailProperties = mailProperties; Set<String> propertyNames = mailProperties.stringPropertyNames(); for(String propName : propertyNames) { try { if( "upload.sender".equals(propName) ) { String value = mailProperties.getProperty(propName); MailRecipient r = MailRecipient.parseString(value); fromAddress = r.getInternetAddress(); } else if( "user.sender".equals(propName) ) { String value = mailProperties.getProperty(propName); MailRecipient r = MailRecipient.parseString(value); fromAddress = r.getInternetAddress(); } } catch(Exception e) { throw new Exception("Problem while parsing key: "+propName, e); } } }
public void setMailProperties(Properties mailProperties) throws Exception { this.mailProperties = mailProperties; Set<String> propertyNames = mailProperties.stringPropertyNames(); for(String propName : propertyNames) { try { if( "upload.approval.url".equals(propName) ) { approvalPageLink = mailProperties.getProperty(propName); logger.info("approvalPageLink: "+approvalPageLink); } else if( "upload.sendNotification".equals(propName) ) { sendUploadMailNotification = Boolean.parseBoolean( mailProperties.getProperty(propName) ); logger.info("sendUploadMailNotification: "+sendUploadMailNotification); } else if( "upload.sender".equals(propName) ) { String value = mailProperties.getProperty(propName); MailRecipient r = MailRecipient.parseString(value); fromAddress = r; } } catch(Exception e) { throw new Exception("Problem while parsing key: "+propName, e); } } }
msg.setFrom( fromAddress ); } else { msg.setFrom( fromRecipient.getInternetAddress() ); for(int loop=0; loop<toAddresses.length; ++loop) { MailRecipient recipient = recipients.get(loop); if( null == recipient.getDisplayName() ) { toAddresses[loop] = new InternetAddress(recipient.getAddress()); } else { toAddresses[loop] = new InternetAddress( recipient.getAddress() ,recipient.getDisplayName() );
public void parseMailProperties(Properties mailProperties) throws Exception { Set<String> propertyNames = mailProperties.stringPropertyNames(); for(String propName : propertyNames) { try { if( "upload.sendNotification".equals(propName) ) { sendUploadMailNotification = Boolean.parseBoolean( mailProperties.getProperty(propName) ); logger.info("sendUploadMailNotification: "+sendUploadMailNotification); } else if( "upload.sender".equals(propName) ) { String value = mailProperties.getProperty(propName); MailRecipient r = MailRecipient.parseString(value); fromAddress = r; } else if( "upload.submission.url".equals(propName) ) { submissionPageLink = mailProperties.getProperty(propName); logger.info("Submission Page URL: "+submissionPageLink); } } catch(Exception e) { throw new Exception("Problem while parsing key: "+propName, e); } } }
private List<MailRecipient> recipientsFromUser(Collection<UserDocument> users){ List<MailRecipient> recipients = new ArrayList<MailRecipient>(users.size()); for(UserDocument user : users){ String display = user.getDisplayName(); Collection<String> emails = user.getEmails(); for(String email : emails){ if( null == display ) { recipients.add( new MailRecipient(email) ); } else { recipients.add( new MailRecipient(email,display) ); } } } return recipients; } }
fromAddress = MailRecipient.parseString(value);
recipients.add( new MailRecipient(emailAddress) );
recipients.add( new MailRecipient(emailAddress) );
recipients.add( new MailRecipient(emailAddress) );
MailRecipient recipient = null; if( null != userName ){ recipient = new MailRecipient(email, userName); } else { recipient = new MailRecipient(email);
for(String email : emails){ if( null == display ) { recipients.add( new MailRecipient(email) ); } else { recipients.add( new MailRecipient(email,display) );
for(String email : emails){ if( null == display ) { recipients.add( new MailRecipient(email) ); } else { recipients.add( new MailRecipient(email,display) );
for(String email : emails){ if( null == display ) { recipients.add( new MailRecipient(email) ); } else { recipients.add( new MailRecipient(email,display) );