/** * Fill email. * * @param email * the email * @throws EmailException * the email exception * @throws IOException * Signals that an I/O exception has occurred. */ public void fillEmail(final MultiPartEmail email) throws EmailException, IOException { email.setHostName(getHost()); email.setSmtpPort(getSmtpPort()); email.addTo(getTo()); email.setFrom(getFrom()); email.setSubject(getSubject()); email.setMsg(getMsg()); email.setSSLOnConnect(isSecured()); if (isRequiresAuthentication()) { email.setAuthentication(getUsername(), getPassword()); } for (int i = 0; i < this.attachements.size(); i++) { final Attachment attachment = this.attachements.get(i); final ByteArrayDataSource ds = new ByteArrayDataSource(attachment.getData(), attachment.getMimeType()); email.attach(ds, attachment.getName(), attachment.getDescription()); } }