VBA: Send an email automatically after saving Excel document

justgoertz

New Member
Joined
Apr 19, 2016
Messages
2
Hello,

I want that when I save my Excel document that I will receive an email with the content of the sheet. So that I will be notified that changes took place and can visually see which changes are made.
For now I have already created the following VBA:

Option Explicit




Sub Mail_Selection_Range_Outlook_Body()


Dim Sendrng As Range


On Error GoTo StopMacro


With Application
.ScreenUpdating = False
.EnableEvents = False
End With



Set Sendrng = Selection(A6)


With Sendrng


ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope



.Introduction = "This is a test mail."


With .Item
.To = "just.goertz@hotmail.com"
.CC = ""
.BCC = ""
.Subject = "TEST"
.Send
End With


End With
End With


StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False


End Sub


Now when I run the Macro i will receive the email with the contents of the sheet. That is great. But I want this to happen when I (or somebody else) saves the document/ or makes any changes. Could somebody help me please?

Thank you in advance.

Kind regards,

Justin
 
Excuse me, above is the wrong Macro. Right now I've got the following Macro:

Sub Send_Selection_Or_ActiveSheet_with_MailEnvelope()



Dim Sendrng As Range


On Error GoTo StopMacro


With Application
.ScreenUpdating = False
.EnableEvents = False
End With




Set Sendrng = Selection



With Sendrng


ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope


.Introduction = "UPDATE"


With .Item
.To = "justin.goertz@hotmail.com"
.CC = ""
.BCC = ""
.Subject = "See following slide"
.Send
End With


End With
End With


StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False


End Sub
 
Upvote 0

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