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 / How to email part of a...
Power Automate
Unanswered

How to email part of an Excel sheet

(0) ShareShare
ReportReport
Posted on by

Using Windows 11 / Power Automate Desktop free version

It's such a simple thing that I've been searching for all day and can't find it.

 

I want to open Excel, select a range of cells, paste them into the body of an email and send it. This is NOT a table. It's just a range of cells. Manually, I can open excel, highlight the range, ctrl-c go to Outlook, GMail, Yahoo, Hotmail, what-ever mail, and paste it into the body. I've tried everything in PAD and can't figure it out.

 

I would much prefer to use gmail on the web, but Outlook desktop is fine too. I just want to paste it and send. 

 

Can someone please point me in the right direction. It would be great if you could offer to help through some private messaging once I get some insight on how to do this very simple task. 

I have the same question (0)
  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @CraigFL ,

     

    Please try the below solution what ever in the excel either its a table or with colur it will paste it in the outlook.

    Please find the solution.

    VishnuReddy1997_0-1717122670255.png

     

    Code:

    Please copy this code to your flow.

    @@copilotGeneratedAction: 'False'
    Scripting.RunVBScript.RunVBScript VBScriptCode: $'''Set objExcel = CreateObject(\"Excel.Application\")
    Set objWorkbook = objExcel.Workbooks.Open(\"C:\\Users\\OneDrive\\Desktop\\Power Automate Desktop\\Practice\\Combine PDFS\\Folder A\\Input.xlsx\")
    Set objWorksheet = objWorkbook.Worksheets(1)
    \' Define variables to store HTML content
    Dim htmlBody
    htmlBody = \"<html><body><table border=\'1\'>\"
    \' Loop through rows and columns to read data and cell colors from Excel
    For row = 1 To objWorksheet.UsedRange.Rows.Count
     htmlBody = htmlBody & \"<tr>\"
     For col = 1 To objWorksheet.UsedRange.Columns.Count
     \' Get cell value
     cellValue = objWorksheet.Cells(row, col).Value
     \' Get cell background color
     cellColor = objWorksheet.Cells(row, col).Interior.Color
     \' Convert Excel color to HTML color
     htmlColor = RGBToHTMLColor(cellColor)
     \' Append cell with color to HTML
     htmlBody = htmlBody & \"<td style=\'background-color:\" & htmlColor & \"\'>\" & cellValue & \"</td>\"
     Next
     htmlBody = htmlBody & \"</tr>\"
    Next
    htmlBody = htmlBody & \"</table></body></html>\"
    \' Close Excel objects
    objWorkbook.Close False
    objExcel.Quit
    \' Output HTML body
    WScript.Echo htmlBody
    \' Function to convert RGB color to HTML color
    Function RGBToHTMLColor(rgb)
     Dim red, green, blue
     red = (rgb Mod 256)
     green = ((rgb \\ 256) Mod 256)
     blue = ((rgb \\ 256 \\ 256) Mod 256)
     RGBToHTMLColor = \"#\" & Right(\"0\" & Hex(red), 2) & Right(\"0\" & Hex(green), 2) & Right(\"0\" & Hex(blue), 2)
    End Function''' ScriptOutput=> htmlBody ScriptError=> ScriptError
    Outlook.Launch Instance=> OutlookInstance
    Outlook.SendEmailThroughOutlook.SendEmail Instance: OutlookInstance Account: $'''varikutivishnuvardhan@acme.com''' SendTo: $'''rajuvallepu@acme.com''' Body: htmlBody IsBodyHtml: True IsDraft: False

    Please change the path of excel in VBscript.

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @CraigFL 

     

    Please follow the below article for your use case:

    (1) Transform SQL Query Results into Stylish HTML Email Tables! | LinkedIn

     

    In your case, instead of fetching data from SQL, please read it from an Excel file and pass your datatable as outlined in the aforementioned article. If you encounter any difficulties, please don't hesitate to reach out.

     

    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 252 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 169

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard