[ 
https://issues.apache.org/jira/browse/EMAIL-153?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

first updated EMAIL-153:
------------------------
    Description: Not applicable  (was: Reporting for the first time.Please let 
me know if I missed anything.

When I send an email with code :

private JavaMailSender mailSender;

mailSender.send(new MimeMessagePreparator() {
                                        @Override
                                        public void prepare(MimeMessage 
mimeMessage) throws MessagingException {
                                                try{
                                                        MimeMessageHelper 
mailMessage = new MimeMessageHelper(mimeMessage, true, "UTF-8");
                                                        
mailMessage.setFrom(from);
                                                        
mailMessage.setSubject(subject);
                                                        mailMessage.setTo(to);
                                                        if(cc!=null)
                                                                
mailMessage.setCc(cc);
                                                        
                                                        
if(fileAttachments!=null && !fileAttachments.isEmpty()){
                                                                ......
                                                                        
mailMessage.addAttachment(fileAttachment.getFileName(), contentsAsResource);
                                                                
                                                        }
                                                        
                                                        if(img!=null && 
!img.isEmpty())
                                                                
getBodyWithImg(mailMessage,imgs, body);
                                                }catch(Exception e){
                                                        _logger.error("Error in 
prepare(..)",e);
                                                }
                                        }
        
                                                private void 
getBodyWithImgs(MimeMessageHelper mailMessage,List<MyImages> imgs,String body) 
throws MessagingException {
                                                                                
                                StringBuffer images = new StringBuffer();
                                                        
                                                                
                                                                        for 
(final Img im: imgs) 
                                                                                
images.append("<img src='cid:"+im.getName()....;
                                                                                
                                                                        
mailMessage.setText(images.toString()+"<br/>"+body, true);
                                                                        
                                                                        
                                                                        for 
(final Img im: imgs) 
                                                                                
attachInline(im,mailMessage);
                                                                        
                                                                
        
                                                private void attachInline(final 
Imgs img,MimeMessageHelper mailMessage) throws MessagingException {
                                                        AbstractResource 
contentsAsResource = someResource();
                                                        
mailMessage.addInline(img.getName(),contentsAsResource);
                                        }
                                                
                        });
                }catch(Exception ex){
                        _logger.error("Error occured while sending mail. Error 
: "+ex.getMessage());
                })

> Not Applicable
> --------------
>
>                 Key: EMAIL-153
>                 URL: https://issues.apache.org/jira/browse/EMAIL-153
>             Project: Commons Email
>          Issue Type: Bug
>            Reporter: first
>            Priority: Blocker
>
> Not applicable



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to