web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Forward email attachme...
Power Automate
Answered

Forward email attachment (image) as an embedded image

(2) ShareShare
ReportReport
Posted on by 26
Hi all,
 
I'm trying to setup a flow to process an email that is received with attachments, then send an email to another user but with the attachment embedded into the email as an image
 
I'm using an apply to each to check I am grabbing the correct image attachment and save it to a sharepoint folder without issues
 
 
If I then use the following statement within 'Send an email (V2)', the image is embedded without any issues
 
<img src="data:@{body('Get_file_content')?['$content-type']};base64,@{body('Get_file_content')?['$content']}">
 
But I want to eliminate the use of saving the file to sharepoint and just embed the attachment into the new email but using the following does not work
 
<img src="data:@{items('Apply_to_each_Attachment')?['$content-type']};base64,@{items('Apply_to_each_Attachment')?['$content']}">
 
Appreciate any advice on this, thanks
 
I have the same question (0)
  • Suggested answer
    Haque Profile Picture
    3,653 on at
    Hi @MM-20111146-0,
     
    Apparently, the issue with your statement (below):
    <img src="data:@{items('Apply_to_each_Attachment')?['$content-type']};base64,@{items('Apply_to_each_Attachment')?['$content']}">
    
    which is not working because the attachment item inside the "Apply to each" loop does not directly contain the base64 content in the ['$content'] property. The items() function returns metadata about the attachment, but the actual binary content must be retrieved separately using a "Get attachment content" action.
     
    How we can fix this:
     
    Inside your Apply to each loop over attachments, add a "Get attachment content" action (or "Get file content" if attachments come from somewhere else) to retrieve the actual base64 content of the current attachment. Use the output of "Get attachment content" in your <img> tag like this:
     
    <img src="data:@{outputs('Get_attachment_content')?['headers']['Content-Type']};base64,@{outputs('Get_attachment_content')?['body']}" />
    
     
    Note:  Replace 'Get_attachment_content' with the exact name of your action. The ['body'] contains the base64-encoded content. The ['headers']['Content-Type'] provides the MIME type.
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
     
     
  • Verified answer
    Valantis Profile Picture
    6,735 on at

    The issue is that email attachment items use different property names than SharePoint file content.
    The `$content` and `$content-type` properties belong to SharePoint/OneDrive file actions.
    Email attachments use `contentBytes` and `contentType` instead.

    You do not need an extra action. Just change your img tag to use the correct property names directly from the attachment item:

    <img src="data:@{items('Apply_to_each_Attachment')?['contentType']};base64,@{items('Apply_to_each_Attachment')?['contentBytes']}">

    This should work without saving to SharePoint at all.

    Note: base64 embedded images do not render in Gmail and may have issues in some desktop Outlook versions, but work in Outlook Web.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

     

  • MM-20111146-0 Profile Picture
    26 on at
    Hi @Hague,
     
    Thanks for the reply
     
     
    I have already setup two compose actions
     
    one to get the contenttype and one to get the actual content
     
    items('Apply_to_each_Attachment')?['contentType']
    items('Apply_to_each_Attachment')?['contentBytes']
     
    These both populate with the correct data

    if I replace the 'Get_attachment_content' to point to my compose items it reports an error in relation to the header
     
    <img src="data:@{outputs('ComposeTest')?['headers']['Content-Type']};base64,@{outputs('ComposeTest')?['body']}" />
     
    error:
    InvalidTemplate. Unable to process template language expressions in action 'Send_an_email_(V2)' inputs at line '0' and column '0': 'The template language expression 'outputs('ComposeTest')['headers']['Content-Type']' cannot be evaluated because property 'headers' cannot be selected. Property selection is not supported on values of type 'String'. Please see https://aka.ms/logicexpressions for usage details.'.
     
    if I remove the headers and use the following, this also reports error as doesn't like contentType
    <img src="data:@{outputs('ComposeContentType')?['contentType']};base64,@{outputs('ComposeContent')?['body']}" />
     
     
    but the following doesn't report an error but doesn't return anything even though the outputs contain data
     
    ComposeContentType = 'image/png'
    ComposeContent = contains the data content which matches what would be output into the saved file
     
    <img src="data:@{outputs('ComposeContentType')?['body']};base64,@{outputs('ComposeContent')?['body']}" />
     
    When creating an action to get the content within the apply to each loop, i can only get the content using items on the apply loop
     
     
  • MM-20111146-0 Profile Picture
    26 on at
    Hi @Valantis,
     
    Thank you for reply
     
    I had initially tried that format but just garbage in the email like below
     
    � W��qS���dj����kg
     
    As though it is not converting back to an image and embedding it into the email
     
    Update: Managed to get it to work (had to rebuild flow from scratch), but still sorting some things out so more testing, etc to do
     
    regards
     
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard