VBA Code for Command Button to Send email

joshadambrown

New Member
Joined
Oct 15, 2018
Messages
4
To be clear, I have little to no understanding of VBA code. All of my work up to this point has been searching forums for codes that do what I need. I am incredibly grateful for those that contribute their knowledge for my gain.

I have a daily update tool that I created in Excel, which I inserted a VBA code that would send an email out to the intended recipients upon saving the file.

In an attempt to make this sheet fool-proof, and avoid inundating our department with emails when a salesman gets click happy on the save button, I would like to insert a command button onto the sheet that will share the sheet when intended.

As a caveat, the first code that I mentioned was great in that it allowed me have the active worksheet insert itself into the body of the email with a little message above it, rather than the file being an attachment.

Is there anyone that can help me with a code that would work for that situation? If I need to provide more information, please let me know.

Thanks in advance

-AB
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Can you post the current code you are using? I think you can get what you want by inserting some simple code to produce a pop up window on save asking if the user wants to email the contents or not.
 
Upvote 0
Can you post the current code you are using? I think you can get what you want by inserting some simple code to produce a pop up window on save asking if the user wants to email the contents or not.


This is the code I am using currently.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)




'Sheets("").Range("").Select '#
ActiveWorkbook.EnvelopeVisible = True

With ActiveSheet.MailEnvelope
.Introduction = "Hello, Accounting - the Negotiated Price Update was saved by " & Environ("USERNAME") & " at " & Format(Now(), "ddd dd mmm yy hh:mm")
.Item.To = "adambrown@duplinmarketingllc.com"
.Item.Subject = "Negotiated Prices Updated"
.Item.display
'.Item.send
End With




End Sub
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

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