In the the code below I have changed the "x" to a checkbox and can not seem to get the syntax correct. Basically on an excel 2010 spreadsheet I have two comments that I am trying to use VB to send an email with the comment selected (checked). Thank you
.
VB
Private Sub CommandButton1_Click()
Dim WS As Worksheet, Rng As Range, c As Range
Dim OutApp As Object, OutMail As Object
Dim Msg As String, Addr As String, FName As String, i As Long
Set OutApp = CreateObject("Outlook.Application")
Set WS = ThisWorkbook.Sheets("Sheet1")
Set Rng = WS.Range("A2", WS.Range("A" & Rows.Count).End(xlUp))
For Each c In Rng
Msg = Msg & "For " & c.Offset(, 1) & Chr(14) & Chr(14)
For i = 3 To 14
If WS.Cells(c.Row, i) = "xlOn" Then
Msg = Msg & " -" & WS.Cells(1, i) & Chr(14)
End If
Next
Msg = Msg & Chr(14) & "Thank you,"
Msg = Msg & Chr(14) & "Christopher McCabe"
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = c.Offset(, 0)
.CC = ""
.BCC = ""
.Subject = "Daily Operational Safety Briefing"
.Attachment = "C:\Users\cmccabe\Desktop\DOSE reporting form 10-14-15.xlsx"
.Body = Msg
.Attachments.Add ("C:\Users\cmccabe\Desktop\DOSE reporting form 10-14-15.xlsx")
.Send
End With
MsgBox "The data has been emailed sucessfully.", vbInformation
Next c
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Bookmarks