I am trying to remind my self for due dates by using below code.After i run it sends me emails for all cases when date is achieved but when i put another due date it did not work if i do not run again.Please i need some help.
Option Explicit
Sub email()
Dim r As Range
Dim cell As Range
Set r = Range("A361:A370")
For Each cell In r
If Date - cell.Value = 30 Then
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = "Reminder"
Email_Send_From = "rdube02@gmail.com"
Email_Send_To = "rdube02@gmail.com"
Email_Cc = ""
Email_Bcc = ""
Email_Body = "Please remind "
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
.send
End With
End If
Next
Exit Sub
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub
Option Explicit
Sub email()
Dim r As Range
Dim cell As Range
Set r = Range("A361:A370")
For Each cell In r
If Date - cell.Value = 30 Then
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = "Reminder"
Email_Send_From = "rdube02@gmail.com"
Email_Send_To = "rdube02@gmail.com"
Email_Cc = ""
Email_Bcc = ""
Email_Body = "Please remind "
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
.send
End With
End If
Next
Exit Sub
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub