Can anyone help me please i am trying to send email using excel based on cell dates but after sending email to 1 email address it gives error "Run Time Error Item Has been moved or deleted" And when i reopen the file it sends email to same id that already has been sent the code i am using is below
Private Sub Workbook_Open()
Dim i As Long
Dim OutApp, OutMail As Object
Dim strto, strcc, strbcc, strsub, strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
For i = 3 To Range("J65536").End(xlUp).Row
If Cells(i, 13) <> "Y" Then
If Cells(i, 8) - 7 < Date Then
strto = Cells(i, 10).Value 'email address
strsub = "RA " & Cells(i, 6).Value & " is due on Due date " & Cells(i, 7).Value 'email subject
strbody = "Dear " & Cells(i, 14).Value & vbNewLine & "please update your project status" 'email body
With OutMail
.To = strto
.Subject = strsub
.Body = strbody
.Send
End With
Cells(i, 11) = "EMail Sent " & Now()
Cells(i, 12) = "Y"
End If
End If
Next
Set OutMail = Nothing
Set OutApp = Nothing
ActiveWorkbook.Save
End Sub
Bookmarks