public URLAttachment(String url, String fileName, ContentDisposition contentDisposition) { super(); URLDataSource uds; try { uds = new URLDataSource(new URL(url)); super.setFileName(fileName); super.setMimeType(uds.getContentType()); super.setContentDisposition(contentDisposition); super.setBytes(Streams.toByteArray(uds.getInputStream())); } catch (MalformedURLException e) { throw new AttachmentException("Wasn't able to create email attachment from URL: " + url, e); } catch (IOException e) { throw new AttachmentException("Wasn't able to create email attachment from URL: " + url, e); } }