I created a sample work book named sample08.xls
I have created two rows and saved it. Then i created the macro as you said.
Then i tried to add another row into the sheet and saved it.
Then i checked my email, but no emails.
yes, i checked my out look email(my work email is already configured to outlook and i gave my work email in the code below).
Do you mind checking if the code actually is working?
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim OutApp As Object
Dim OutMail As Object
Const SendTo As String = "myname@company.com"
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = SendTo
.Subject = ThisWorkbook.sample08 " has been amended"
.Body = " add a message here"
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Bookmarks