Send Email when Date field satisfyies cretaria

Advait

New Member
Joined
Jan 15, 2015
Messages
1
[TABLE="width: 500"]
<tbody>[TR]
[TD] Sr.No
[/TD]
[TD]SOP Title
[/TD]
[TD]expiry Date
[/TD]
[TD]Email Id
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]IT06
[/TD]
[TD]15-Feb-2015
[/TD]
[TD]abc@xyz.com
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]IT07
[/TD]
[TD]14-May-2015
[/TD]
[TD]cef@xyz.com
[/TD]
[/TR]
</tbody>[/TABLE]
Hi. Am new to this forum and this is my first post.

I want that when the date field is satisfied an email is triggered. Attached is the excel file. The email should be sent 30 days before the expiry date mentioned to the expiry date column
[TABLE="width: 714"]
<colgroup><col width="44" style="width: 33pt; mso-width-source: userset; mso-width-alt: 1609;"><colgroup><col width="447" style="width: 335pt; mso-width-source: userset; mso-width-alt: 16347;"><colgroup><col width="77" style="width: 58pt; mso-width-source: userset; mso-width-alt: 2816;"><colgroup><col width="129" style="width: 97pt; mso-width-source: userset; mso-width-alt: 4717;"><colgroup><col width="255" style="width: 191pt; mso-width-source: userset; mso-width-alt: 9325;"><tbody>[TR]
[TD="width: 44, bgcolor: transparent"][/TD]
[TD="width: 447, bgcolor: transparent"][/TD]
[TD="width: 77, bgcolor: transparent"][/TD]
[TD="width: 129, bgcolor: transparent"][/TD]
[TD="width: 255, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent, align: right"][/TD]
[TD="bgcolor: transparent, align: right"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]
 
Welcome to the board!

How about?
Code:
Option Explicit
Sub CheckDates()
Dim Rng As Range
For Each Rng In Worksheets("sheet2").Range("C2:C" & Range("C" & Rows.Count).End(xlUp).Row)
    If IsEmpty(Rng) = False Then
        If Rng.Value < DateAdd("d", 30, Date) Then
            Call SendEMail(Rng)
        End If
    End If
Next Rng
        
End Sub
Sub SendEMail(Rng As Range)
'For Tips see: [url=http://www.rondebruin.nl/win/s1/outlook/bmail4.htm]Mail a small message[/url]
'Working in Office 2000-2013
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    strbody = "Hi there" & vbNewLine & vbNewLine & _
              Rng.Offset(0, -2) & " " & Rng.Offset(0, -1) & vbNewLine & _
              "is due within 30 days" & vbNewLine & vbNewLine & _
              "Thank you" & vbNewLine & _
              "Signed"
    On Error Resume Next
    With OutMail
        .To = Rng.Offset(0, 1)
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .Body = strbody
        'You can add a file like this
        '.Attachments.Add ("C:\test.txt")
        '.Send   'or use
        .Display
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top