cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JohnB2
Helper I
Helper I

Embed image in email from powerapps- help

Hi,

Looking for more help/advice.

 

So, I have an "App" that is connected to a sharepoint list. User can update the list and attach images.

 

For the user to upload the image im using "Add Picture" and then in that function its getting updated to SharePoint list and changed to base64 using below formula.

 

Patch(
    'Generator Inspection',
    LookUp('Generator Inspection', ID = Gallery4.Selected.ID),
    {
       'Generator Changeover Switch':Substitute(
            JSON(
                UploadedImage1.Image,
                JSONFormat.IncludeBinaryData
                ),
                """",
                ""
            )
    }
        );

 

I have proved it works it works as below you can see the data in the list and I have also pullled that data into the app with the "Image" function and it displays the image as it should.

JohnB2_0-1661180407376.png

Where I'm getting stuck now is, embedding that image into an email once a button is pressed. Below is the code I am using to send the email. The email sends okay, but what ever I try, the image will not appear in the email. 

 

Set(varChangeSwitch,(Gallery4.Selected.'Generator Changeover Switch'));

Office365Outlook.SendEmailV2(
        "email address", //yes, I have removed my email address for this form :)
        "Test", //Subjsect
        "<img src=" & varChangeSwitch & ">");

     

 

1 ACCEPTED SOLUTION

Accepted Solutions
JohnB2
Helper I
Helper I

Hi,

Thanks for that, he clearly explains everything.

But it didn't solve my issue. But I figured it out!!. 

 

When I was setting the base64 string from the data card as a string(in the below code), I was pointing it to the whole data card and not the text value in that data card🙈.

 

Once I corrected that, it worked no problem. Silly me. I really should stop and have a look at what I'm doing from time to time 😂😂.

 

 

 

Set(varChangeSwitch,(Gallery4.Selected.'Generator Changeover Switch'));

Office365Outlook.SendEmailV2(
        "email address", //yes, I have removed my email address for this form :)
        "Test", //Subjsect
        "<img src=" & varChangeSwitch & ">");

 

 

 

View solution in original post

4 REPLIES 4
BrianS
Super User
Super User

If I remember correctly, to get the image to show you need to strip out the "data&colon;image/jpeg;base64," header to get to the actual base64 data. Some images end up with "png" instead of "jpeg" in the header

JohnB2
Helper I
Helper I

Hi,

Thanks for replying but no joy with your suggestion

I manually put the base64 string into the email instead of a variable to try also - no good.

I put the base64 string into an online base64 - image converter to prove to myself the data string is okay - and it was.

I even created a new app just to test the email with the string to see if my app got somehow corrupted. Same result.

 

By any chance am I doing something silly with the email formula?

BrianS
Super User
Super User

After looking I think you do want the whole string. The email call looks correct. You may need quotes around the base64 string. I would watch this video - Shane lays out everything.  

JohnB2
Helper I
Helper I

Hi,

Thanks for that, he clearly explains everything.

But it didn't solve my issue. But I figured it out!!. 

 

When I was setting the base64 string from the data card as a string(in the below code), I was pointing it to the whole data card and not the text value in that data card🙈.

 

Once I corrected that, it worked no problem. Silly me. I really should stop and have a look at what I'm doing from time to time 😂😂.

 

 

 

Set(varChangeSwitch,(Gallery4.Selected.'Generator Changeover Switch'));

Office365Outlook.SendEmailV2(
        "email address", //yes, I have removed my email address for this form :)
        "Test", //Subjsect
        "<img src=" & varChangeSwitch & ">");

 

 

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,212)