How do you export an Excel sheet to Outlook?

Samantha Gomes 40 Reputation points
2023-08-23T19:18:19.5366667+00:00

Hello,

I need help with the final step in the EoD report I have created. The EoD is written up in excel, its full of info on the amount of hours we worked on different builds, employee breakdowns, etc.

I have been trying to find a way to use a script or Power Automate, to put the cell and their data into an Outlook email. However, all my searching keeps returning other stuff, like how to export outlook into excel or how to use excel to get an email address for an oncall list.
How do I fill an Outlook email with the data and formatting I have in my EoD Excel sheet? Copy/Pasting is not a good option as it looks really really ugly in Outlook sadly.

Any help would be greatly appreciated!

Outlook | Windows | Classic Outlook for Windows | For business
Microsoft 365 and Office | Excel | For business | Windows
{count} votes

2 answers

Sort by: Most helpful
  1. Tanay Prasad 2,250 Reputation points
    2023-08-24T09:29:51.0733333+00:00

    Hi,

    I did some research and found how it is to be done.

    1. Go to your Excel sheet and open your VBE.
    2. Create a new module.
    3. Paste the below code. (please make changes as per your requirements)
    4. Close the VBA Editor.
    5. Press Alt+f8 and select the SendExcelDataInExcel macro and click on "Run".
    Sub SendExcelDataInEmail()
        Dim OutApp As Object
        Dim OutMail As Object
        Dim MyWorkbook As Workbook
        Dim MyWorksheet As Worksheet
        Dim StrBody As String
        Dim RecipientEmailAddress As String
        
        ' Create a reference to the Outlook application
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
        
        ' Set the Excel workbook and worksheet
        Set MyWorkbook = ThisWorkbook ' Assumes you are working with the active workbook
        Set MyWorksheet = MyWorkbook.Sheets("SheetName") ' Replace "SheetName" with the name of your sheet
        
        ' Define the email subject
        OutMail.Subject = "End of Day Report"
        
        ' Add recipients (To, CC, BCC)
        RecipientEmailAddress = "recipient@example.com" ' Change this to the recipient's email address
        OutMail.To = RecipientEmailAddress
        OutMail.CC = "cc@example.com" ' You can add CC recipients
        OutMail.BCC = "bcc@example.com" ' You can add BCC recipients
        
        ' Define the email body
        StrBody = "Hello," & vbCrLf & vbCrLf & _
                  "Please find the End of Day report attached." & vbCrLf & vbCrLf & _
                  "Best regards," & vbCrLf & _
                  "Your Name"
        
        ' Add body content to the email
        OutMail.Body = StrBody
        
        ' Attach the Excel workbook to the email
        MyWorkbook.Save ' Save the workbook
        MyWorkbook.Close ' Close the workbook
        OutMail.Attachments.Add MyWorkbook.FullName
        
        ' Display the email and send
        OutMail.Display
        'OutMail.Send ' Uncomment this line to send the email automatically
        
        ' Clean up
        Set OutMail = Nothing
        Set OutApp = Nothing 
    End Sub
    

  2. Michelle Ran 346 Reputation points Microsoft Employee
    2023-09-08T19:48:51.05+00:00

    You can try modifying this tutorial: https://learn.microsoft.com/en-us/office/dev/scripts/resources/samples/email-images-chart-table

    Specifically, replace the script in the tutorial with the following:

    function main(workbook: ExcelScript.Workbook) {
        return workbook.getWorksheet('Worksheet name here').getRange('Range address here').getImage();
    }
    
    

    This will grab an image of the specified range and return it to the Power Automate flow to send via email. Let me know if that helps, or if you have any questions!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.