Excel to generate auto emails for missed deadlines

Eternal Student

New Member
Joined
Aug 11, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
HI

I would like Excel to auto generate an email through Outlook if a project deadline is missed. This would also apply to the second and third deadline. Each email would have a different body sent to the recipient.
The trigger would be the project status cell(s) under columns " O, Q and S ".

1691769421814.png


Thank you.

Regards,

VN
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
VBA Code:
Sub SendEmail()
Application.ScreenUpdating = False
Dim EmailApp As Outlook.Application
Dim Source As String
Set EmailApp = New Outlook.Application

Dim EmailItem As Outlook.MailItem
Dim wdDoc As Object
Dim oRng As Object
Dim olInsp As Object


Dim LastRow As String

FirstDeadlineEmail = "C:\Users\John\Desktop\FirstDeadlineEmail.msg" 'Path to First Email Draft .msg file
SecondDeadlineEmail = "C:\Users\John\Desktop\SecondDeadlineEmail.msg" 'Path to Second Email Draft .msg file
ThirdDeadlineEmail = "C:\Users\John\Desktop\ThirdEmail.msg" 'Path to Third Email Draft .msg file
    
LastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

For R = 2 To LastRow
    If Range("S" & R).Value = "Deadline Missed" Then 'Change this to whatever wording you require
        Set EmailItem = EmailApp.CreateItemFromTemplate(ThirdDeadlineEmail)
        EmailItem.To = Cells(R, 1) 'Cell address containing Recipients email address
    
        With EmailItem
            'Comment out Display and uncomment send to issue automatically
            .Display
            '.send
        End With
    ElseIf Range("Q" & R).Value = "Deadline Missed" Then 'Change this to whatever wording you require
        Set EmailItem = EmailApp.CreateItemFromTemplate(SecondDeadlineEmail)
        EmailItem.To = Cells(R, 1) 'Cell address containing Recipients email address
        With EmailItem
            'Comment out Display and uncomment send to issue automatically
            .Display
            '.send
        End With
    ElseIf Range("O" & R).Value ="Deadline Missed" Then 'Change this to whatever wording you require
        Set EmailItem = EmailApp.CreateItemFromTemplate(FirstDeadlineEmail)
        EmailItem.To = Cells(R, 1) 'Cell address containing Recipients email address
        With EmailItem
   
            .Display
            '.send
        End With
    End If
Next R

End Sub
 
Upvote 0
Thank you so much for your response / solution. To extend this, will this pull a pre-type message in the body of the email as each escalating email will have different data. Thank you
 
Upvote 0

Forum statistics

Threads
1,215,165
Messages
6,123,387
Members
449,098
Latest member
ArturS75

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