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

first updated EMAIL-153:
------------------------
    Summary: Not Applicable  (was: Email with body only test give garbage value)

> Not Applicable
> --------------
>
>                 Key: EMAIL-153
>                 URL: https://issues.apache.org/jira/browse/EMAIL-153
>             Project: Commons Email
>          Issue Type: Bug
>            Reporter: first
>            Priority: Blocker
>
> 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());
>               }



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

Reply via email to