public void sendHtmlMail(String from, String[] to, String title, String text)
            throws AddressException, MessagingException {

        long start = System.currentTimeMillis();

        MimeMessage mimeMessage = mailSender.createMimeMessage();
        MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "GBK");

        InternetAddress[] toArray = new InternetAddress[to.length];
        for (int i = 0; i < to.length; i++) {
            toArray[i] = new InternetAddress(to[i]);
        }

        messageHelper.setFrom(new InternetAddress(from));
        messageHelper.setTo(toArray);
        messageHelper.setSubject(title);
        messageHelper.setText(text, true);
        mimeMessage = messageHelper.getMimeMessage();
        mailSender.send(mimeMessage);
        long end = System.currentTimeMillis();
        LOG.info("send mail start:" + start + " end :" + end);
    }
public void sendHtmlMail ( String from , String [ ] to , String title , String text ) throws AddressException , MessagingException { long start = System . currentTimeMillis ( ) ; MimeMessage mimeMessage = mailSender . createMimeMessage ( ) ; MimeMessageHelper messageHelper = new MimeMessageHelper ( mimeMessage , true , "GBK" ) ; InternetAddress [ ] toArray = new InternetAddress [ to . length ] ; for ( int i = 0 ; i < to . length ; i ++ ) { toArray [ i ] = new InternetAddress ( to [ i ] ) ; } messageHelper . setFrom ( new InternetAddress ( from ) ) ; messageHelper . setTo ( toArray ) ; messageHelper . setSubject ( title ) ; messageHelper . setText ( text , true ) ; mimeMessage = messageHelper . getMimeMessage ( ) ; mailSender . send ( mimeMessage ) ; long end = System . currentTimeMillis ( ) ; LOG . info ( "send mail start:" + start + " end :" + end ) ; }
发送html邮件

@throws MessagingException
@throws AddressException