3 Replies Latest reply on Apr 9, 2009 2:30 AM by joblini

    Seam Mail Inline Image Attachment

    toppac.toppac.gmail.com

      What is the best approach for attaching inline images? I thought from reading the docs I could attach an image using a String value but it doesnt seem to work. If I have to write a utility method to read the image into a byte array that is fine. Just looking for the best approach. I have the following



      <m:attachment 
                  value="/WEB-INF/img/mail/banner.PNG" 
                  contentType="image/png"         
                  status="banner" 
                  disposition="inline" />



      Which I then try to reference as



      <img width="728" height="53" id="_x0000_i1025" src="cid:#{banner.contentId}"/>



      But I get



      17:54:11,793 INFO  [STDOUT] ss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
              at net.nike.gate.ui.action.user.UserRequestAction_$$_javassist_21.sendMail(UserRequestAction_$$_javassist_21.java)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
              at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:342)
              at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
              at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
              at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
              at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
              at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
              ... 50 more
      Caused by: java.lang.LinkageError: loader constraints violated when linking javax/activation/DataHandler class
              at org.jboss.seam.mail.ui.UIAttachment.encodeEnd(UIAttachment.java:167)
              at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:181)
              at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163)
              at org.jboss.seam.mail.ui.UIMessage.encodeChildren(UIMessage.java:167)
              at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:175)
              at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163)
              at org.jboss.seam.ui.facelet.FaceletsRenderer.renderFacelet(FaceletsRenderer.java:207)
              at org.jboss.seam.ui.facelet.FaceletsRenderer$1.process(FaceletsRenderer.java:161)
              at org.jboss.seam.ui.facelet.FaceletsRenderer$RenderingContext.run(FaceletsRenderer.java:79)
              at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:170) 
              ... 102 more
      




        • 1. Re: Seam Mail Inline Image Attachment
          toppac.toppac.gmail.com

          I seemed to have found the problem myself. We had duplicate copies of DataHandler on the classpath. Removing them now attaches the images (had to remove the leading forward slash from the path) but the images are not showing inline still. In outlook I can see there are attachments and the headers are there



          ------=_Part_0_1847394.1236303054514
          Content-Type: image/png; name=banner.PNG
          Content-Transfer-Encoding: base64
          Content-ID: <xxpwfbifexdxdxnywiys>
          Content-Disposition: inline; filename=banner.PNG
          
          ------=_Part_0_1847394.1236303054514
          Content-Type: image/png; name=footer.PNG
          Content-Transfer-Encoding: base64
          Content-ID: <hzhmmocssxypaegtdodj>
          Content-Disposition: inline; filename=footer.PNG




          The content IDs match what is in the message source



          <img id="_x0000_i1025" height="51" src="cid:xxpwfbifexdxdxnywiys" width="700" />
          <img id="_x0000_i1034" height="26" src="cid:hzhmmocssxypaegtdodj" width="700" border="0" />




          But they still are not showing. Any suggestions?

          • 2. Re: Seam Mail Inline Image Attachment
            toppac.toppac.gmail.com

            Was able to resolve this issue as well. Our ant build was corrupting the images in the packaging process by doing a copy with filtering. I had to do a separate copy command with filter off for the images. Everything seems to work now.

            • 3. Re: Seam Mail Inline Image Attachment
              joblini

              Thanks for posting this.  Just what I was looking for!