Hi guys,
this looks to see if a date is in the past, then if column H is NOT at 100% it sends and email, but i can't get it to use the email address i enter into column L?
can anyone help? always debugs at .To = .Cells(2, "L").Value
Private Sub Workbook_Open()
'#
'# declare private variables
'#
Dim OutApp As Object
Dim OutMail As Object
'#
'# only send an e-mail when the date in column E is before today and column H is less than 100%
'#
With ThisWorkbook.Worksheets("Sheet1")
If .Cells(2, "E").Value <= Date And LenB(.Cells(2, "H") < 1) Then
'#
'# start an instance of the Outlook application to send the e-mail
'#
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
'#
'# create and send the e-mail
'#
With OutMail
.To = .Cells(2, "L").Value
.CC = vbNullString
.BCC = vbNullString
.Subject = ThisWorkbook.Name
.Body = "Hi Sarah," & vbLf & "This range is either late for handing over, or the PIC hasn't populated a date in CT HO column " & ThisWorkbook.Name
'.Send
.display
End With
'#
'# highlight the date in column "E"
'#
With .Cells(2, "E").Font
.Color = -16776961
.TintAndShade = 0
End With
End If
End With
'#
'# housekeeping
'#
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Bookmarks