0

add an image to the body text in SendEmail

Is it possible to add an image field directly into the SendEmail body (ie say a jpeg or PNG file)

in my following script below I do add an attachment  file (which is fine)

But I would like to also do is add a static image with the body text 

 

so this looks like .....

 

this or similar png file is added to the bottom of the above message (in the body that the client sees in their email client

 

Had a few goes at it but I cant seem to make it work

so whereas as I pick up the attachment. 

let myAtt := first(files(record(SystemFile,1)));

i want to pick the an image up in the same manner (always the same for each client)

ie something like  let myImage := first(files(record(SystemFile,2)));

 

my current script (with adding the image line in)

if Status < 2 or Status > 3 then
    alert("job Status is not in production")
else
    Status := 3;
    if not 'Email+' then
        alert("No valid contact in email field")
    else
        if DispFlag = 1 then
            alert("Dispatched Confirmation already sent!")
        else
            let thisBody := first((select SystemFile).OrderDispatchedLetter);
            let myEmail := userEmail();
            let myAtt := first(files(record(SystemFile,1)));
            thisBody := replace(thisBody, "{Ord Company}", text('Ord Company'));
            thisBody := replace(thisBody, "{Order Name}", text('Order Name'));
            thisBody := replace(thisBody, "{Job Bag}", text('Job Bag'));
            thisBody := replace(thisBody, "{Order Date}", text('Order Date'));
            thisBody := replace(thisBody, "{Order Name}", 'Order Name');
            thisBody := replace(thisBody, "{Order Ref}", 'Order Ref');
            thisBody := replace(thisBody, "{Qty}", text(Qty));
            thisBody := replace(thisBody, "{Desc}", Desc);
            thisBody := replace(thisBody, "{Del Company}", text('Del Company'));
            thisBody := replace(thisBody, "{Del Address}", text('Del Address'));
            DispFlag := 1;
            sendEmail({
                from: myEmail,
                to: 'Email+',
                subject: "Your order has been dispatched by 118 Printgroup",
                text: "Goods Dispatched Confirmation",
                html: thisBody,
                attachments: myAtt
            });
            alert("Goods Dispatched Email has been Sent");
            DisplayMenu := 1
        end
    end
end

10 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    I gues you can use the function shareFile() on your imagefield and use this in your body like kinda displaying an image  in html page.

      • Mel_Charles
      • 1 yr ago
      • Reported - view

      RoSoft_Steven oh that as a thought ! - I will give this a go - thank you

      • Alan_Cooke.1
      • 1 yr ago
      • Reported - view

      Mel Charles If this works could you drop the working script here I would be interested to try this out.

    • Mel_Charles
    • 1 yr ago
    • Reported - view

    Ninox support have come back and said - currently it is not possible to make this work :😟

      • Ninox partner
      • RoSoft_Steven.1
      • 1 yr ago
      • Reported - view

      Mel Charles Alan Cooke

      (And @support) 😝

      Ninox support have come back and said - currently it is not possible to make this work :😟

      This code works with me:

      let sha := shareFile(record(Settings,1).Image);
      let img := "<img src='" + sha + "' alt='Image'>";
      let sender := userEmail();
      let receiver := Email;
      let subj := Subject;
      let txt := Text;
      let bod := raw(Body);
      let bod := replace(bod, "{IMAGE}", img);
      sendEmail({
          from: sender,
          to: receiver,
          subject: subj,
          text: txt,
          html: bod
      })

      So, in table 'Settings' there is an Image field: Image and I put the shared URL of this image in the variable sha (line1), then i make a text-line to display an image in a html page in the variable img(line 2).

      The field Body is a rich-text field and contains a text-portion {IMAGE} which I replace with the variable img (line 8).

      If I should done this already in the Body field, my code(like it would be contained in my img-variable) would be interpreted like text. It's because we use raw() we can add html-tags to the body.

      So, in the same way we can add color to certain text also (since we can't do that in the rich text editor), but this would be a lesson in html...

      Maybe I'll post an example later in the Learn&Share section of this forum.

      Hope this helps you guys.👍

      Steven

    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    Mel Charles

    Did this work out for you?

    • NetSol Co., Ltd.
    • Bernd_Krell
    • 1 yr ago
    • Reported - view

    Hmmm. I added a Rich Text to my form. When I paste an image in this field and then send the form as an email, the image doesn't get send along. The text int he Rich Text field is received, not the image though.

    We need this to work when submitting reports to customers.
    One should expect that "everything" in the rich text field will be submitted 😔

    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    check this post for example database : https://forum.ninox.com/t/x2h7fm9

    Steven

    • NetSol Co., Ltd.
    • Bernd_Krell
    • 1 yr ago
    • Reported - view

    I figured out the best option for me and our reports.

    I created a print form and the print form shows all images which I add into the Rich Text field just fine. Then I create a button which generates the PDF and sends it by email. That solves my issue, hopefully yours as well.

      • NetSol Co., Ltd.
      • Bernd_Krell
      • 1 yr ago
      • Reported - view

      Bernd Krell Well, I was a bit too fast. Oversized pictures simply get cut in the print form. There is no option to auto-resize or resize to fit. They should implement this in the Rich Text form to allow resizing images.

      Another bummer 😟

Content aside

  • 1 yr agoLast active
  • 10Replies
  • 275Views
  • 4 Following