Hello. Currently I use the following code to send emails out via a click box on on of my excel sheets. I was wondering if anyone thinks its possible to have check boxes for different departments (there are 6 departments) and only have the email go to the departments I have ticked?
Private Sub CommandButton1_Click()
'Updated by Extendoffice 2017/9/14
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Body content" & vbNewLine & vbNewLine & _
"Hi - An update - please see attached." & vbNewLine & _
"Many thanks."
On Error Resume Next
With xOutMail
.To = "XXXXX@X.com"
.CC = "XXXXX@t.com........etc etc"
.BCC = ""
.Subject = "Data Analysis UPDATE"
.Body = xMailBody
.Attachments.Add ActiveWorkbook.FullName
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Private Sub CommandButton1_Click()
'Updated by Extendoffice 2017/9/14
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Body content" & vbNewLine & vbNewLine & _
"Hi - An update - please see attached." & vbNewLine & _
"Many thanks."
On Error Resume Next
With xOutMail
.To = "XXXXX@X.com"
.CC = "XXXXX@t.com........etc etc"
.BCC = ""
.Subject = "Data Analysis UPDATE"
.Body = xMailBody
.Attachments.Add ActiveWorkbook.FullName
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub