cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
StephenGW
Helper IV
Helper IV

Image in Email

Hello all,

 

I have created an app for entering data into OneDrive and Excel. The app works good. I also have added an email which is so close to working but I need to add an image in the HTML Body of the email. I have to rely on the Mail connector (no attachment choice) because I cannot use Outlook due to the exchange server error and cannot migrate. Here is what I have so far. I use the AddMediaWithImage to get the picture. For the AddMediaButton I have this to collect and then I think convert to 64bit OnSelect.

 

ClearCollect(ClickedPhoto,{Name:"Picture",ContentBytes:UploadedImage1.Image, '@odata,type':""});Set(ClickedPhotoVar,JSON(ClickedPhoto,JSONFormat.IncludeBinaryData ));Set(ClickedPhoto64,Mid(ClickedPhotoVar,24,Len(ClickedPhotoVar)-24))

 

I then add it into the HTML like this.

 

"<p><font size='6' color='red'><b>**** Do Not Reply To This Email ****</b></font><br><br><font size='3' color='black'><b>Please review findings</b></font><br><font size='6' color='black'><b>"&ddDepartment.Selected.Result&" Audit Findings</b></font><br><br><font size='3' color='black'><b>Auditor: </b>"&ddAuditor.Selected.Auditor&"</font><br><br><font size='3' color='black'><b>Area: </b>"&ddArea.Selected.Result&"</font><br><br><font size='3' color='red'><b>Pass/Fail: </b>"&ddPass.Selected.'Pass/Fail'&"</font><br><br><font size='3' color='black'><b>Issue Found: </b>"&tiIssue.Text&"</font><br><br><font size='3' color='black'><b>Person Notified: </b>"&ddNotify.Selected.Result&"</font><br><br><font size='3' color='black'><b>Picture: </b></font>,img src=ClickedPhoto64><br><br><font size='3' color='black'><b>Additonal Findings: </b>"&tiAdditonal.Text&"</Font><br><br><font size='3' color='black'><b>Safety Findings: </b>"&tiSafety.Text&"</Font></p>"

 

But this remains a broken image in the email. Anybody have any ideas on how I can make this work? I really need the image with the email.

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

@StephenGW - For the reference of anyone else reading this, I guess this was the eventual solution to your problem?

https://powerusers.microsoft.com/t5/Building-Power-Apps/Email-Image-base64/m-p/899101#M285297

 

Mail.SendEmailV3(ddTo.Selected.'Emails (Emails)'&","&tiAddNote.Text,
                 tiSubject.Text,
                 HTMLBody.HtmlText,
                 true,
                 {
                   filenames:AddMediaButton1.FileName,
                   files:UploadedImage1.Image
                 }
)

 

View solution in original post

9 REPLIES 9
timl
Super User
Super User

@StephenGW 

Perhaps someone has a better suggestion, but I think you would need to save the images to an Internet accessible location and to reference the URL in your email.

There is an issue in that the majority of email clients don't show inline, base64 encoded images.

https://stackoverflow.com/questions/16242489/send-a-base64-image-in-html-email

That's the likely reason why you see a broken image in your email, and the reason why this type of requirement is challenging.

@timl 

 

At the end of my app I use this to send it to the Excel sheet which also adds the image to a folder in OneDrive and then it send the email right after, then exits the app. Would there be anyway to grab the link created in the folder in OneDrive after the patch but then include it in the email portion?

 

Patch(Data,Defaults(Data),{Date:DatePicker1.SelectedDate,Location:ddLocation.Selected.'Locations (Locations)',Auditor:ddAuditor.Selected.Auditor,Department:ddDepartment.Selected.Result,Area:ddArea.Selected.Result,'Pass/Fail':ddPass.Selected.'Pass/Fail','Issues Found':tiIssue.Text,'Person Notified':ddNotify.Selected.Result,Picture:UploadedImage1.Image,'Additonal Findings':tiAdditonal.Text,'Safety Findings':tiSafety.Text});Mail.SendEmailV3(ddTo.Selected.'Emails (Emails)',tiSubject.Text,HTMLBody.HtmlText,true)

 

Thanks,

Stephen

mequan
Community Support
Community Support

Hello,

Actually Outlook will not show Image if it doesn't  think IMAGE file is safe. So if you want to show image in mail, you need to add image file as Email attachment and let email show it.

 

Thanks

timl
Super User
Super User

Hi @StephenGW 

Unfortunatlely, there's no way that I know of to grab the link to the file in OneDrive following the Patch.

Attaching images from OneDrive is always problematic due to authentication.

As @mequan says, the easiest way to include your picture would be to add it as an attachment, although the disadvantage of this would be that it won't appear in line.

 

 

 

 

@timl 

 

Thank you. Unfortunately it does not look like the Mail connector allows attachments and I am currently unable to use Outlook connectors due to the exchange server error.

 

Thank you for all your great help!

timl
Super User
Super User

You're welcome @StephenGW 

Just for info, the SendEmailV3 method does enable you to pass a single attachment and attachment name as the last argument to the method.

mequan
Community Support
Community Support

Correct , After attach image, you can use attached IMG file in HTML as an element

timl
Super User
Super User

@StephenGW - For the reference of anyone else reading this, I guess this was the eventual solution to your problem?

https://powerusers.microsoft.com/t5/Building-Power-Apps/Email-Image-base64/m-p/899101#M285297

 

Mail.SendEmailV3(ddTo.Selected.'Emails (Emails)'&","&tiAddNote.Text,
                 tiSubject.Text,
                 HTMLBody.HtmlText,
                 true,
                 {
                   filenames:AddMediaButton1.FileName,
                   files:UploadedImage1.Image
                 }
)

 

View solution in original post

@timl 

 

Sorry, I forgot to add a reply here but yes that was the solution I needed.

 

Thanks,

Stephen

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,537)