excel01noob
Board Regular
- Joined
- Aug 5, 2019
- Messages
- 93
- Office Version
- 365
- 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
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