question: private MimeMessage createMimeMessage ( Session session , MailMessage mailMessage ) throws MessagingException { String subject = mailMessage . getSubject ( ) ; if ( subjectPrefix != null && ! subjectPrefix . equals ( "" ) ) { subject = subjectPrefix + " " + subject ; } MimeMultipart content = new MimeMultipart ( "related" ) ; DataSource [ ] attachments = mailMessage . getAttachmentsArray ( ) ; for ( DataSource attachment : attachments ) { MimeBodyPart attachmentPart = createAttachmentPart ( attachment ) ; content . addBodyPart ( attachmentPart ) ; } MimeBodyPart bodyPart = createMessageBodyPart ( mailMessage . getBody ( ) , mailMessage . isBodyHtml ( ) ) ; content . addBodyPart ( bodyPart ) ; MimeMessage message = new MimeMessage ( session ) ; if ( from == null ) { message . setFrom ( ) ; } else { message . setFrom ( new InternetAddress ( from ) ) ; } InternetAddress [ ] to = createAddresses ( mailMessage . getToArray ( ) ) ; if ( to . length == 0 ) { to = InternetAddress . parse ( defaultTo ) ; } message . setRecipients ( Message . RecipientType . TO , to ) ; InternetAddress [ ] cc = createAddresses ( mailMessage . getCcArray ( ) ) ; message . setRecipients ( Message . RecipientType . CC , cc ) ; InternetAddress [ ] bcc = createAddresses ( mailMessage . getBccArray ( ) ) ; message . setRecipients ( Message . RecipientType . BCC , bcc ) ; message . setSubject ( subject ) ; message . setContent ( content ) ; return message ; }
target:  Creates the mime message.