private void addAttachment ( Multipart multipart , Attachment attachment ) throws AttachmentResourceHandlerException { MimeBodyPart part = new MimeBodyPart ( ) ; try { part . setFileName ( attachment . getResource ( ) . getName ( ) ) ; part . setDisposition ( attachment . getDisposition ( ) ) ; part . setDescription ( attachment . getDescription ( ) ) ; part . setContentID ( attachment . getContentId ( ) ) ; attachmentHandler . setData ( part , attachment . getResource ( ) , attachment ) ; multipart . addBodyPart ( part ) ; } catch ( MessagingException e ) { throw new AttachmentResourceHandlerException ( "Failed to attach " + attachment . getResource ( ) . getName ( ) , attachment , e ) ; } }
Add an attachment on the mime message .