I declared a variable for FormulaCell, and used it as the LastRow
Try this:
Option Explicit
Sub Mail_with_outlook1()
'For mail code examples visit my mail page at:
'http://www.rondebruin.nl/sendmail.htm
Dim OutApp As Object
Dim OutMail As Object
Dim strto As String, strcc As String, strbcc As String
Dim strsub As String, strbody As String
Dim FormulaCell As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set FormulaCell = Sheet1.Range("a65536").End(xlUp)
strto = Cells(FormulaCell.Row, "K").Value
strcc = ""
strbcc = ""
strsub = "Review Date Due"
strbody = "Hi there" & vbNewLine & vbNewLine & _
"Review date of " & Cells(FormulaCell.Row, "A").Value & _
" titled " & Cells(FormulaCell.Row, "B").Value & _
" located at:" & vbNewLine & vbNewLine & Cells(FormulaCell.Row, "L").Value & vbNewLine & vbNewLine & _
" is due on " & Cells(FormulaCell.Row, "D").Value & "." & _
vbNewLine & vbNewLine & "Please take appropriate action." & _
vbNewLine & vbNewLine & "Best Regards," & _
vbNewLine & vbNewLine & "Asif Shabbir"
With OutMail
.To = strto
.CC = strcc
.BCC = strbcc
.Subject = strsub
.Body = strbody
'You can add a file to the mail like this
'.Attachments.Add ("C:\test.txt")
.Display ' or use .Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Bookmarks