excel to send as attachment and as image in body of email

excel01noob

Board Regular
Joined
Aug 5, 2019
Messages
93
Office Version
  1. 365
  2. 2016
Hi

Might be quite complicated but can I have a macro preparing to send the data as an attachment to the email but also as a table in the body of the email ?

I have this macro for the attached file

Sub Mail_Sheet()
Dim wPath As String, wFile As String, dam As Object
Dim wMail As String, wSubj As String, wBody As String

Application.ScreenUpdating = False
Application.DisplayAlerts = False

wFile = "Payments report VD " & Format(Date, "dd-mm-yyyy")
wPath = ThisWorkbook.Path & ""

wSender = Sheets("email").Range("A2").Value
wMail = Sheets("email").Range("B2").Value
wCC = Sheets("email").Range("C2").Value
wSubj = Sheets("email").Range("D2").Value
wBody = Sheets("email").Range("E2").Value

Sheets("payment list").Copy

ActiveWorkbook.SaveAs Filename:=wPath & wFile & ".xlsx"
ActiveWorkbook.Close False

Set dam = CreateObject("Outlook.Application").CreateItem(0)
dam.To = wMail
dam.SentOnBehalfOfName = wSender
dam.Subject = wSubj
dam.body = wBody
dam.Attachments.Add wPath & wFile & ".xlsx"
dam.Display '

Set dam = Nothing

End Sub


and I have using this one for the table in the email body

https://www.vba-market.com/excel-vba-insert-excel-table-into-body-of-email-message/

but trying to combine both it's an issue currently
 
You don't want to save the file, but you want to send a copy of the file?

If you don't want to send the file and just want to send the range, then also delete this lines:
Code:
  wFile = "Payments report VD " & Format(Date, "dd-mm-yyyy")
  wPath = ThisWorkbook.Path & "\"


  Sheets("payment list").Copy
  ActiveWorkbook.SaveAs Filename:=wPath & wFile & ".xlsx"
  ActiveWorkbook.Close False

  dam.Attachments.Add wPath & wFile & ".xlsx"

Hi DanteAmor

different people use the same info, while some would prefer to have the table in the body of email, others prefer to have it in excel format.....
So, finally I need to send both the table and excel but I do not need to save the excel as copy.
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I do not understand.
To send the excel file you have to save the file as excel.
You can save the file, send it and then delete the file.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top