Hello,
I need help adding text to the subject line of emails that are automatically generated from a spreadsheet I am creating. Basically I just want to have the text from cell J3 entered after the "Reminder" statement. Here is what I have so far.
Sub email()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim strbody As String
For Each cell In Range("K3:K21")
strbody = strbody & cell.Value & vbNewLine
Next
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "C").Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Reminder "
.Body = "Dear " & Cells(cell.Row, "A").Value & vbNewLine & vbNewLine & strbody
.Importance = 2
.ReadReceiptRequested = True
.Attachments.Add ("C:\Users\test")
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Thanks!
I need help adding text to the subject line of emails that are automatically generated from a spreadsheet I am creating. Basically I just want to have the text from cell J3 entered after the "Reminder" statement. Here is what I have so far.
Sub email()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim strbody As String
For Each cell In Range("K3:K21")
strbody = strbody & cell.Value & vbNewLine
Next
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "C").Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Reminder "
.Body = "Dear " & Cells(cell.Row, "A").Value & vbNewLine & vbNewLine & strbody
.Importance = 2
.ReadReceiptRequested = True
.Attachments.Add ("C:\Users\test")
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Thanks!