Forum Stats

  • 3,816,046 Users
  • 2,259,133 Discussions
  • 7,893,368 Comments

Discussions

Email campaign image issue

RicardoS
RicardoS Member Posts: 3 Green Ribbon

Hey,

I have built an email campaign which allows the client to send emails giving their new username and login.

Everything is working well except, when I add an image to display at the bottom of the email (company logo) it doesn't grab said image, I added the image in the HTML getting the image which is saved on the static application files.

I have tried numerous ways which include adding the image to the static workplace files, using the image URL, changing the HTML code but all seem to have the same outcome, no image displayed.

I would attach screenshots but I have tried so many different ways.

Tagged:

Comments

  • Billy Verreynne
    Billy Verreynne Software Engineer Member Posts: 28,803 Red Diamond

    There are 3 basic ways to add an image to HTML e-mail.

    Via an URL to the image on a web server. This will be blocked by default by most e-mail readers, and needs to be explicitly allowed by the user for the mail reader to access it.

    By base64 encoding of the image into the SRC attribute of the IMG element. E.g.

    <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2
    wCEAAkGBxITEBMUEhAVFRIWFRYWGBUVGSQeFRkhIBIWHBciFh8kICgsHyAxIBYX
    ...">
    

    Or attaching the image to the e-mail, and pointing the SRC attribute of the IMG element to the attachment's content identifier. E.g.

    <img src="cid:attachment-content-id">
    
  • RicardoS
    RicardoS Member Posts: 3 Green Ribbon
    edited Jul 29, 2021 1:20PM

    @Billy Verreynne here's my HTML code, I haven't yet tried the base 64 encoding yet, just unsure how to store it as I presume it would need to be shortened. (This is using the email templates)

    <b>Dear #CUSTOMER#,</b><br>

    <br>

    You have been granted access to ESA Risk's Debtabase.</b><br>

    <br>

    <table width="100%">  

      <tr>

        <th align="left">Username</th>

        <td>#USERNAME#</td>

      </tr>

      <tr>

        <th align="left">Password</th>

        <td>#PASSWORD#</td>

      </tr>  

      <br>

        <th align="left" valign="top">Please login at https.//app.debtabase.com, where you will be prompted to change your password.</th>

      </br>  

      <tr>

        <th align="left" valign="top">Kind regards,</th>

      </tr>

        <tr>

        <th align="left" valign="top">Debtabase Administration Team</th>

      </tr>

      <tr>

    </table>

    <br>

    <img src="#APP_IMAGES#ESA-RISK.jpg" width="100" height="100"/>

    </br>

  • Billy Verreynne
    Billy Verreynne Software Engineer Member Posts: 28,803 Red Diamond
    edited Jul 29, 2021 1:41PM

    Unsure whether doing an inline encode of an image (especially one more than 12KB) is a good idea. Worth a try if smaller.

    I prefer attaching the image to the e-mail and using a content-id reference to the attachment. I have however my own custom MIIME parser for creating the raw e-mail headers and body. Have not tried APEX e-mail interface and templates.

    PS. sending full user credentials (name and password together), and including the logon URL, via unsecure medium like e-mail is a serious security risk

  • InoL
    InoL Member Posts: 9,802 Gold Crown

    <img src="#APP_IMAGES#ESA-RISK.jpg" width="100" height="100"/>

    Application images cannot be used outside an APEX session, so your email cannot retrieve the image. Store your image somewhere on a web server.

    I wouldn't go the base64 route. A lot of mail clients cannot handle base64 embedded images. I found this article:


    CID works, but not with APEX_MAIL. You will need to write your own mail procedure. I have a very old feature request for that:


  • jariola
    jariola Member Posts: 10,735 Silver Crown

    Application images cannot be used outside an APEX session, so your email cannot retrieve the image.

    @InoL , I think that isn't true at least on APEX 20.x and later. Or I do I miss something

    InoL
  • InoL
    InoL Member Posts: 9,802 Gold Crown

    I never realized that, but you are right, This is a static image in my application on apex.oracle.com:

    So, for the OP: this is not enough:

    <img src="#APP_IMAGES#ESA-RISK.jpg" width="100" height="100"/>

    You need the complete path, not the relative path.

    jariola