Topic
7 replies Latest Post - ‏2013-10-31T21:14:44Z by CBradley
SystemAdmin
SystemAdmin
7615 Posts
ACCEPTED ANSWER

Pinned topic Email with embed images

‏2012-12-03T20:56:30Z |
Hi,

I'm trying to send emails using the "Send E-mail via SMTP" service. I've already been capable of achieve almost all the requeriments except one, add a embed image in the email body.

I've tried several options, and my last failure was:





My question is, if this is possible how can I do it?

Any help will be welcome.

Best regards.
Updated on 2012-12-05T01:11:30Z at 2012-12-05T01:11:30Z by SystemAdmin
  • kolban
    kolban
    3314 Posts
    ACCEPTED ANSWER

    Re: Email with embed images

    ‏2012-12-03T22:08:13Z  in response to SystemAdmin
    Imagine IBM BPM was not involved. What would you have to code as the body of an email in order to show an image? I think the way that emails work when you wish to show an image is not attaching the image with the email but instead providing the HTML that shows the image via a URL.

    You can attach the image as an attachment to the email, but that isn't the same as showing the image in an HTML aware email client.

    Neil
    • SystemAdmin
      SystemAdmin
      7615 Posts
      ACCEPTED ANSWER

      Re: Email with embed images

      ‏2012-12-04T00:16:51Z  in response to kolban
      Hi Neil,

      I saw approaches two differente approaches.
      The first the image is provided as a managed resource and it's used the url. The second one is setting the url in the src attribute form img tag.
      But in both approaches there little fallbacks. In the first the managed resource's url isn't acessible everywhere and in the second is necessary provide a image by exposing a url.

      So a third option emerged, using a base64 enconded image and embed it in the email body.
      The attached file is a example of what I want to achieve, if possible.

      Best regards,
      • kolban
        kolban
        3314 Posts
        ACCEPTED ANSWER

        Re: Email with embed images

        ‏2012-12-04T00:50:18Z  in response to SystemAdmin
        I think you pretty much answered your own question. When sending the email, set the content encoding to "text/html" and set the body of the email to the HTML that you described in your last post.

        Neil
        • SystemAdmin
          SystemAdmin
          7615 Posts
          ACCEPTED ANSWER

          Re: Email with embed images

          ‏2012-12-05T01:11:30Z  in response to kolban
          Hi Neil,

          I tried embed the html in the email body but I only get a blank email.
          Because of this I will choose one of the two others options.

          If I or someone, discover a solution for use the third option I will put it here.
          Maybe use a multipart content encoding or use an image CID could do the trick.

          Once more, thank you for your help.
  • rtlenaha
    rtlenaha
    60 Posts
    ACCEPTED ANSWER

    Re: Email with embed images

    ‏2013-10-25T16:53:48Z  in response to SystemAdmin

    Ensure that your content type is set to text/html for connecting to the email service (whether it is Email Send Teamworks Email - which defaults to that value for the content type - or Send Email via SMTP). 

    Next, add the image as a Managed Web File.  In the scriptlet that you associate with the body of the email, and in the <body> tag, you would put:

    <img src="<#= tw.system.model.findManagedFileByPath("MyGif.gif", TWManagedFile.Types.Web).url #>">

    It should then display in the email that you send.

     

    • SanketSahoo
      SanketSahoo
      73 Posts
      ACCEPTED ANSWER

      Re: Email with embed images

      ‏2013-10-31T20:21:34Z  in response to rtlenaha

      Hi ,

      I am getting the below error:-

      uncaught exception: Error

       

      • CBradley
        CBradley
        82 Posts
        ACCEPTED ANSWER

        Re: Email with embed images

        ‏2013-10-31T21:14:44Z  in response to SanketSahoo

        Make sure you are doing this in a scriplet that is bound to a variable that is a string.

        Also make sure you have attached the image as a managed file (of type web file)  and you are calling it out appropriately.

        Then check your syntax on the img src tag, and make sure that you have it inside the <body>  </body> tags.

        One thing you could try is to assign this to a variable in an earlier script box and see if that works to just do that

         

        var myImg = tw.system.model.findManagedFileByPath("MyGif.gif", TWManagedFile.Types.Web).url

        That should show you if you can at least get the image out of the managed file using this method. Also play around with the different methods for TWManagedFile and see if the other ones are working at all

         

        And you might add some error handling so that you can catch the error