

Note: The VBA code is only working when you use Outlook as your email program. Please send the email by clicking the Send button. See screenshot:įrom now on, every time you click on the Command Button, an email will be created automatically with specified recipients, subject and body. Turn off the Design Mode by clicking Developer > Design Mode. Press the Alt + Q keys simultaneously to close the Microsoft Visual Basic for Applications window.ĥ. Subject = "Test email send by button clicking".Ĥ. Specify the Cc and Bcc recipients as you need in. Replace the Email Address with the recipient email address in line. Please change the email body as you need in the xMailBody line in the code.Ģ). Subject = "Test email send by button clicking"ġ). XMailBody = "Body content" & vbNewLine & vbNewLine & _ Set xOutApp = CreateObject("Outlook.Application") VBA code: Send email if button is clicked in Excel Private Sub CommandButton1_Click() In the opening Microsoft Visual Basic for Applications window, please replace the original code in the Code window with the following VBA script. Right-click the inserted Command Button, then click View Code from the right-clicking menu as below screenshot show.ģ. Insert a Command Button in your worksheet by clicking Developer > Insert > Command Button (ActiveX Control). Please do as follows to send an email through Outlook if a Command Button is clicked in Excel workbook.ġ. Send email if button is clicked with VBA code Supposing you need to send email through Outlook by clicking a button in Excel worksheet, how can you do? This article will introduce a VBA method to achieve it in details.

How to send email if button is clicked in Excel?
