Using Excel Office 365. This is the Module. I'm sure it is something very simple but it is driving me crazy. It sends the email perfectly when I hit "run" from Developer, Macros. I need it to run when the Workbook opens. This code is in a module for "Sheet 16". The dates are in the two columns. Thanks for your help.
Option Explicit
Sub email()
Dim r As Range
Dim cell As Range
Set r = Range("D3:D300", ["G3:G200"])
For Each cell In r
If cell.Value = Date Then
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "SOW OUT - SOW NEW D & G"
On Error Resume Next
With OutMail
.To = "gaias@comcast.net"
.CC = "online2007@comcast.net"
.BCC = ""
.Subject = "ALERT"
.Body = strbody
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End If
Next
Exit Sub
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub
Bookmarks