Email with Checkbox

lynrhall

New Member
Joined
Apr 4, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
When checkbox1 is checked - it should send an email using outlook. If the checkbox1 should get unchecked, it shouldn't do anything. Right now anytime I click the check box it sends an email. I have tried an if then statement, but am getting runtime errors.

This is my code I have for the checkbox:

Sub CheckBox1_Click()

Dim OutlookApp As Object
Dim eItem As Object
Dim tid As String
Dim cOwner As String
Dim tOwner As String
Dim elist As String

Set OutlookApp = CreateObject("Outlook.Application")
Set eItem = OutlookApp.CreateItem(0)
tid = Sheet1.Range("A3").Text
cOwner = Sheet1.Range("G3").Text
tOwner = Sheet1.Range("E3").Text
elist = Sheet6.Range("D4").Value

If Sheet1.Shapes("Check Box 1").Value = True Then

With eItem
.to = elist
.Subject = "Audit Evidence Review Notice"
.HTMLBody = "" & cOwner & ", <br><br>" & _
"" & tOwner & " has completed evidence collection for " & tid & ".<br><br>" & _
"Evidence Location: Zoho Workdrive > SOC 2 Evidence > CA-100 > TA-100.1A<br><br>" & _
"Contact " & tOwner & " directly with any questions or concerns about the " & tid & " evidence.<br><br>" & _
"Go to the Compliance Application.xlsm to approve the evidence."
.Send
End With
MsgBox "" & cOwner & " has been successfully notified."

Else
End If

End Sub

Thank you!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
It looks like you have a Form control checkbox. If so, your IF statement should be as follows . . .

VBA Code:
If sheet1.Shapes("Check Box 1").ControlFormat.Value = xlOn then

Notice that you need to refer to the ControlFormat property of the Shape object in order to access the shape's control properties. See the following link . . .


Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,916
Members
449,093
Latest member
dbomb1414

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