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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Send an email to staff...
Power Automate
Answered

Send an email to staff with a random image from a Onedrive folder

(0) ShareShare
ReportReport
Posted on by 16

I am trying to send an email to staff with a random image from a onedrive folder.  I am not sure where it is going wrong, any help would be great.

Screenshot 2022-10-12 114211.jpg

 

 

Categories:
I have the same question (0)
  • Sundeep_Malik Profile Picture
    6,484 on at

    Hey @Fshaw213 

    You should use another action before this, like list files in a folder. Then get id of a file, maybe the first file as you are sending random images.

    Btw how are you getting that id????

  • srduval Profile Picture
    1,760 Moderator on at

    Part of the problem is the @{ I think that is preventing the compose output from being resolved to it's actual value. That's why you are seeing that as part of the literal output.

     

  • Fshaw213 Profile Picture
    16 on at

    Hey no luck, it just returns the same error. I copied the gauide from this post https://powerusers.microsoft.com/t5/Using-Flows/Birthday-Email-to-Include-Random-Images/td-p/831741

    Fshaw213_0-1665608953463.png

     

  • Fshaw213 Profile Picture
    16 on at

    When I do it this way it creates the appropriate output but it doesn't recognise the file.

    Fshaw213_1-1665609198662.png

     

  • srduval Profile Picture
    1,760 Moderator on at

    That action is looking for guid, not name. The example you copied from is sharepoint, which i wouldn't be surprised if the example as shown didn't/doesn't work either for the same reason that the action typically looks for a guid. If you use the folder icon and browse to the file you want then under the elipse, look at peek code, you'll see it's resolved to a guid. 

     

    Try changing your get file content to be a Get file content using path action instead. That should accept the dynamic path you are trying to send it. 

  • Fshaw213 Profile Picture
    16 on at

    It's close, now I don't know why but it doesn't send it as a jpeg it just sends it as a file.

    Fshaw213_0-1665622704426.png

    Fshaw213_1-1665622806458.pngFshaw213_2-1665622820658.png

     

     

  • Verified answer
    srduval Profile Picture
    1,760 Moderator on at

    Somewhere in the attachment process you should be specifying a name, make sure you add the extension (4.jpg)

  • pradeep_kumar Profile Picture
    42 on at

    But I want to embedded these randomly image on an email body 

  • RobElliott Profile Picture
    10,323 Super User 2025 Season 2 on at

    The flow to add a randomly-selected image from a OneDrive folder to an email is as follows:

    1-Flow.png

     

    Add a OneDrive get file content action and add the expression
    outputs('List_files_in_folder')?['body/value'][rand(0,length(outputs('List_files_in_folder')?['body/value']))]?['Id']

    2-Flow.png

     

    Then in the Send an email action, click the code view </> button and oin the img src line add the expression

     

    dataUri(outputs('Get_file_content')?['body'])

    3-Flow.png

     

    Run the flow and an email will arrive with a random image from the OneDrive folder:

    4-Email.png

     

    Run it again and a different random image will be in the email:

     

    5-Email.png

     

    Rob
    Los Gallardos
    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

  • pradeep_kumar Profile Picture
    42 on at

    Hi,

     

    Thanks for reply but i want to insert image in email body then i work on that such as insert teammate name on that image and insert some another image on that

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard