10. RPA Challenge - Copy Information in Excel and Save as Image?


I would like to insert a image in the body of the email. This image is from a excel. I want to copy range of cells from the excel and save it as a image. Load the image as a variable and insert it into the body of the email and send out. Does anybody know how to do it? Thanks a lot!

Automation Challenge Winners

Moved it to RPA Challenge


Finished this, but i think my solution is stupid. I was unable to save the Image took from excel (get from clipboard doesn’t work)

Attached is solution, may have selector issues. I think running macro to take screenshot and saving file to a location is a far better idea.

ImageFromExcel.zip (226.0 KB)

Outlook image issue
Excel copy 3 row named range down 1 row and make the new cells the new named range

Thanks a lot!!! We are inspired by your solution. We create a new object by choosing the "Bitmap Image"type and save the image in a file. This solution is not that smart but it works. Thank you!


Could you please share?


Hello Everyone,

This is MHO on how to get this done. this is using outlook 2013 also will get the last row in case the data change, also if outlook is not open, if is not will open outlook and will send the image.

Please take a look and let me know if this works. Happy automation.

RPA_10.zip (591.7 KB)


I think something like this

                Rectangle bounds = this.Bounds;
                using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
                    using (Graphics g = Graphics.FromImage(bitmap))
                        g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
                    bitmap.Save(path, ImageFormat.Png);


Looks like you pasting the image by opening outlook.Figure out a way to avoid that, I used paint which can be avoided. I tried below code but not sure how to implement highlighted code in Uipath (doesn’t work using Invoke method)

     bmp = Clipboard.GetImage()
    JpegBitmapEncoder encoder = new JpegBitmapEncoder();
    BitmapFrame outputFrame = BitmapFrame.Create(bmp);
    encoder.QualityLevel = quality;

using (FileStream file = File.OpenWrite(fileName))

PS: watched 80% of the movies :wink:


Please kindly help why i always get like picture shows, Thanks!


If you still are still in need of this…


We can copy the range to a new dummy sheet, take screens hot and send an email. Since image should be in the body, we should build the html for send mail message body content and check ishtml property for the activity, so that the image appears as body. Later we can delete the dummy sheet or not save the excel.


We can copy from excel sheet and paste in paint and save this image ImageAttachInMail.xaml (18.4 KB)


This might be a bit late, but I got the solution for this. Combinations of techniques and answers I got from forum and google. Took me sometime as well to figure, here it is:

  1. Use the ‘Invoke Code’ activity to copy Excel Range to Image.
    [a] strExcelFile
    [b] strImageFileName
    [c] Range (Optional)

Dim xlPicture As Microsoft.Office.Interop.Excel.XlCopyPictureFormat
Dim xlScreen As Microsoft.Office.Interop.Excel.XlPictureAppearance
Dim objExcel As Microsoft.Office.Interop.Excel.Application = Nothing
Dim objWorkbook As Microsoft.Office.Interop.Excel.Workbook = Nothing
Dim objSheet As Microsoft.Office.Interop.Excel.Sheets = Nothing
Dim objWorkSheet As Microsoft.Office.Interop.Excel.Worksheet = Nothing
Dim oRangeToCopy As Microsoft.Office.Interop.Excel.Range

On Error Resume Next
''Create Excel Object
objExcel = New Microsoft.Office.Interop.Excel.ApplicationClass
objWorkbook = objExcel.Workbooks._Open(strExcelFile)
objExcel.DisplayAlerts = False

''Get Sheet
objSheet = objWorkbook.Sheets
objWorkSheet = CType(objSheet(1), Microsoft.Office.Interop.Excel.Worksheet)

''Get Range
oRangeToCopy = objWorkSheet.Range(“A2:D55”)
oRangeToCopy.CopyPicture(Microsoft.Office.Interop.Excel.XlPictureAppearance.xlScreen, Microsoft.Office.Interop.Excel.XlCopyPictureFormat.xlPicture)

''Create Shape for Chart
Dim shape As Microsoft.Office.Interop.Excel.Shape
shape= objWorkSheet.Shapes.AddChart(Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered, CDbl(oRangeToCopy.Left.ToString), CDbl(oRangeToCopy.Top.ToString), CDbl(oRangeToCopy.Width.ToString), CDbl(oRangeToCopy.Height.ToString))

''Save Excel File

''Destroy objects
objWorkSheet = Nothing
objWorkbook = Nothing
objExcel = Nothing
On Error GoTo 0

Note: I used shape to be able to create a chart, was trying to use the chartobject/s but it was throwing some exceptions. Got stuck on this one for long.

  1. Send Email - I used ‘Send Outlook Mail Message’ (Will move this via SMTP)
    As some have suggested, make use of the ‘IsBodyHtml’ property and create an html code for the body.
    This is the one I used for the image part and works fine. Just change the path to variable to make it dynamic. Can remove the width and height, I just added for mine as the image we have is quite long.

img src=‘D:\UIPATH\Image_130518_075410401.jpg’ Width = ‘5500’ Height =‘15000’
img src=’" & strImageFileName & "’ Width = ‘5500’ Height =‘15000’




Here is my attempt I’m just automating button pushes on the whole rather than the integrated activities for Excel and Outlook so it’s probably not the best solution?

I’m using Office 365 (in case that makes a difference to the selectors).

All the best,

Chall10_CopyRangeFromExcelAsImage.zip (114.8 KB)