public void embed ( URL url , String cid , String name ) throws EmailException { // verify that the URL is valid try { InputStream is = url . openStream ( ) ; is . close ( ) ; } catch ( IOException e ) { throw new EmailException ( "Invalid URL" ) ; } MimeBodyPart mbp = new MimeBodyPart ( ) ; try { mbp . setDataHandler ( new DataHandler ( new URLDataSource ( url ) ) ) ; mbp . setFileName ( name ) ; mbp . setDisposition ( "inline" ) ; mbp . addHeader ( "Content-ID" , "<" + cid + ">" ) ; this . inlineImages . add ( mbp ) ; } catch ( MessagingException me ) { throw new EmailException ( me ) ; } }
Embeds an URL in the HTML .