VBA to send reminder email if no response

Status
Not open for further replies.

maheshbabu

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
Halo Team,

I am looking for a VBA to send follow up/reminder email if there is no response received within 1 day. The action should happen on emails where subject line states "Attention".

I found few VBA codes however I am getting an error. "Compile error: Only valid in object module"

Below is the part of the code where am getting error.

Private WithEvents olSentItems As Items

Thank you in advance for your help.
 
Thanks for your reply. I tried running the code from the Outlook session as suggested, still I don't see the result.

Is there any other code. Because I have 50 - 80 reminder emails to send on weekly basis.

Your help on this would be very much appreciated.

Thank you in advance for your support as always.
 
can you post the code you are using?
 
I got the code from below blog/fourm:

How to Get a Notification If Not Receiving the Reply of a Specific Email within Expected Time - Data Recovery Blog


Public WithEvents objInboxItems As Outlook.Items

Private Sub Application_Startup()
Set objInboxItems = Application.Session.GetDefaultFolder(olFolderInbox).Items
End Sub

'If receive the reply, clear the flag and remove the reminder
Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
Dim objSentItems As Outlook.Items
Dim objVariant As Variant
Dim i As Long
Dim strSubject As String
Dim dSendTime As String

Set objSentItems = Outlook.Application.Session.GetDefaultFolder(olFolderSentMail).Items

If Item.Class = olMail Then
For i = 1 To objSentItems.Count
If objSentItems.Item(i).Class = olMail Then
Set objVariant = objSentItems.Item(i)
strSubject = LCase(objVariant.Subject)
dSendTime = objVariant.SentOn

If LCase(Item.Subject) = "re: " & strSubject Or InStr(LCase(Item.Subject), strSubject) > 0 Then
If Item.SentOn > dSendTime Then
With objVariant
.ClearTaskFlag
.ReminderSet = False
.Save
End With
End If
End If
End If
Next i
End If
End Sub

'Get a prompt asking if to send a notification email
Private Sub Application_Reminder(ByVal Item As Object)
Dim strPrompt As String
Dim nResponse As Integer
Dim objFollowUpMail As Outlook.MailItem

'You can change the subject as per your real case
If (Item.Class = olMail) And (LCase(Item.Subject) = "datanumen outlook repair") Then
strPrompt = "You haven't yet recieved the reply of " & Chr(34) & Item.Subject & Chr(34) & " within your expected time. Do you want to send a follow-up notification email?"
nResponse = MsgBox(strPrompt, vbYesNo + vbQuestion, "Confirm to Send a Follow-Up Notification Email")
If nResponse = vbYes Then
Set objFollowUpMail = Application.CreateItem(olMailItem)
With objFollowUpMail
.To = Item.Recipients.Item(1).Address
.Subject = "Follow Up: " & Chr(34) & Item.Subject & Chr(34)
.Body = "Please respond to my email " & Chr(34) & Item.Subject & Chr(34) & "as soon as possible"
.attachments.Add Item
.Display
End With
End If
End If
End Sub
 
Hi,

Did you get a chance to look into the above scenario, if yes any update on the same.
 
I would be interested in reading the response from Diana, this is topic I was long time interested in...
 
Hello, I'm also very much interested in a solution for the problem "sending email reminder, if no reply to my sent email received."

Thanks Diane,

Gregor
 
I didn't test it, but the macro posted above should work - the first macros check the sent folder for matching messages and clear the sent flag. The last one is triggered by a reminder.

If the reminder is on an email and has the specified subject, it asks if you want to send a followup. While you could tweak it to send it automatically, it's usually better to ask, just in case a flag/reminder was not removed. If you want to check all mail reminders, remove the subject clause. Using categories would be another option - then set categories on either all flagged sent mail or only on flagged incoming mail.

For example, if you use a send followup category on sent mail, use this to exit the macro if the category is something else. The remove And (LCase(Item.Subject) = "datanumen outlook repair") from the code so it doesn't check the subject.
Code:
If Item.Categories <> "Send Followup" Then
     Exit Sub
End If


Code:
If (Item.Class = olMail) And (LCase(Item.Subject) = "datanumen outlook repair") Then
strPrompt = "You haven't yet recieved the reply of " & Chr(34) & Item.Subject & Chr(34) & " within your expected time. Do you want to send a follow-up notification email?"
nResponse = MsgBox(strPrompt, vbYesNo + vbQuestion, "Confirm to Send a Follow-Up Notification Email")
If nResponse = vbYes Then
Set objFollowUpMail = Application.CreateItem(olMailItem)

it doesn't look like the code dismisses the reminder - i would do that and maybe remove the flag and category.

I have these two macros that show how to use random subjects and dismiss the reminder.
Send an Email When a Reminder Fires
Receive a Reminder When a Message Doesn't Arrive?

If you need to check your own Inbox for messages to remind you to reply if too much time has passed, this macro can do it:
Forward Messages that were not Replied To
 
Last edited:
I got the code from below blog/fourm:

How to Get a Notification If Not Receiving the Reply of a Specific Email within Expected Time - Data Recovery Blog


Public WithEvents objInboxItems As Outlook.Items

Private Sub Application_Startup()
Set objInboxItems = Application.Session.GetDefaultFolder(olFolderInbox).Items
End Sub

'If receive the reply, clear the flag and remove the reminder
Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
Dim objSentItems As Outlook.Items
Dim objVariant As Variant
Dim i As Long
Dim strSubject As String
Dim dSendTime As String

Set objSentItems = Outlook.Application.Session.GetDefaultFolder(olFolderSentMail).Items

If Item.Class = olMail Then
For i = 1 To objSentItems.Count
If objSentItems.Item(i).Class = olMail Then
Set objVariant = objSentItems.Item(i)
strSubject = LCase(objVariant.Subject)
dSendTime = objVariant.SentOn

If LCase(Item.Subject) = "re: " & strSubject Or InStr(LCase(Item.Subject), strSubject) > 0 Then
If Item.SentOn > dSendTime Then
With objVariant
.ClearTaskFlag
.ReminderSet = False
.Save
End With
End If
End If
End If
Next i
End If
End Sub

'Get a prompt asking if to send a notification email
Private Sub Application_Reminder(ByVal Item As Object)
Dim strPrompt As String
Dim nResponse As Integer
Dim objFollowUpMail As Outlook.MailItem

'You can change the subject as per your real case
If (Item.Class = olMail) And (LCase(Item.Subject) = "datanumen outlook repair") Then
strPrompt = "You haven't yet recieved the reply of " & Chr(34) & Item.Subject & Chr(34) & " within your expected time. Do you want to send a follow-up notification email?"
nResponse = MsgBox(strPrompt, vbYesNo + vbQuestion, "Confirm to Send a Follow-Up Notification Email")
If nResponse = vbYes Then
Set objFollowUpMail = Application.CreateItem(olMailItem)
With objFollowUpMail
.To = Item.Recipients.Item(1).Address
.Subject = "Follow Up: " & Chr(34) & Item.Subject & Chr(34)
.Body = "Please respond to my email " & Chr(34) & Item.Subject & Chr(34) & "as soon as possible"
.attachments.Add Item
.Display
End With
End If
End If
End Sub
I didn't test it, but the macro posted above should work - the first macros check the sent folder for matching messages and clear the sent flag. The last one is triggered by a reminder.

If the reminder is on an email and has the specified subject, it asks if you want to send a followup. While you could tweak it to send it automatically, it's usually better to ask, just in case a flag/reminder was not removed. If you want to check all mail reminders, remove the subject clause. Using categories would be another option - then set categories on either all flagged sent mail or only on flagged incoming mail.

For example, if you use a send followup category on sent mail, use this to exit the macro if the category is something else. The remove And (LCase(Item.Subject) = "datanumen outlook repair") from the code so it doesn't check the subject.
Code:
If Item.Categories <> "Send Followup" Then
     Exit Sub
End If


Code:
If (Item.Class = olMail) And (LCase(Item.Subject) = "datanumen outlook repair") Then
strPrompt = "You haven't yet recieved the reply of " & Chr(34) & Item.Subject & Chr(34) & " within your expected time. Do you want to send a follow-up notification email?"
nResponse = MsgBox(strPrompt, vbYesNo + vbQuestion, "Confirm to Send a Follow-Up Notification Email")
If nResponse = vbYes Then
Set objFollowUpMail = Application.CreateItem(olMailItem)

it doesn't look like the code dismisses the reminder - i would do that and maybe remove the flag and category.

I have these two macros that show how to use random subjects and dismiss the reminder.
Send an Email When a Reminder Fires
Receive a Reminder When a Message Doesn't Arrive?

If you need to check your own Inbox for messages to remind you to reply if too much time has passed, this macro can do it:
Forward Messages that were not Replied To
Hi, i tried this code but it is not working.

I have tried with the subjectline but i am not getting any prompt for reminder. Could you please suggest.
 
I didn't test it, but the macro posted above should work - the first macros check the sent folder for matching messages and clear the sent flag. The last one is triggered by a reminder.

If the reminder is on an email and has the specified subject, it asks if you want to send a followup. While you could tweak it to send it automatically, it's usually better to ask, just in case a flag/reminder was not removed. If you want to check all mail reminders, remove the subject clause. Using categories would be another option - then set categories on either all flagged sent mail or only on flagged incoming mail.

For example, if you use a send followup category on sent mail, use this to exit the macro if the category is something else. The remove And (LCase(Item.Subject) = "datanumen outlook repair") from the code so it doesn't check the subject.
Code:
If Item.Categories <> "Send Followup" Then
     Exit Sub
End If


Code:
If (Item.Class = olMail) And (LCase(Item.Subject) = "datanumen outlook repair") Then
strPrompt = "You haven't yet recieved the reply of " & Chr(34) & Item.Subject & Chr(34) & " within your expected time. Do you want to send a follow-up notification email?"
nResponse = MsgBox(strPrompt, vbYesNo + vbQuestion, "Confirm to Send a Follow-Up Notification Email")
If nResponse = vbYes Then
Set objFollowUpMail = Application.CreateItem(olMailItem)

it doesn't look like the code dismisses the reminder - i would do that and maybe remove the flag and category.

I have these two macros that show how to use random subjects and dismiss the reminder.
Send an Email When a Reminder Fires
Receive a Reminder When a Message Doesn't Arrive?

If you need to check your own Inbox for messages to remind you to reply if too much time has passed, this macro can do it:
Forward Messages that were not Replied To

Hi Diane

Category as trigger is a much better solution works like a charm, thanks for this Diane.
With your other suggestion above to dismiss the reminder and remove flag and category it would be almost perfect. Any chance you could help me out here with code strings ? This would help me to see whats open and whats done.

Thx Joacim
 
Hi, i tried this code but it is not working.

I have tried with the subjectline but i am not getting any prompt for reminder. Could you please suggest.
Did you change this line to looks for the keywork in the subject and use all lower case?
If (Item.Class = olMail) And (LCase(Item.Subject) = "datanumen outlook repair") Then
 
To remove a flag / reminder before it fires, you'll clear the flag and set reminders to false and set categories to blank using "". If you use categories and want to clear a specific category, I have code for that somewhere.

Code:
.ClearTaskFlag
.ReminderSet = False
.Categories= ""


Dismiss the reminder - its from this page

Code:
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)

    For Each objRem In olRemind
            If objRem.Caption = strSubject Then
                If objRem.IsVisible Then
                    objRem.Dismiss
                    Cancel = True
                End If
                Exit For
            End If
        Next objRem

End Sub
 
To remove a flag / reminder before it fires, you'll clear the flag and set reminders to false and set categories to blank using "". If you use categories and want to clear a specific category, I have code for that somewhere.

Code:
.ClearTaskFlag
.ReminderSet = False
.Categories= ""


Dismiss the reminder - its from this page

Code:
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)

    For Each objRem In olRemind
            If objRem.Caption = strSubject Then
                If objRem.IsVisible Then
                    objRem.Dismiss
                    Cancel = True
                End If
                Exit For
            End If
        Next objRem

End Sub

Thanks Diane i will try this, appreciate the help
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
A Change settings Send/receive VBA Outlook VBA and Custom Forms 0
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
stephen li VBA Outlook send mail automatically by specified outlook mail box Outlook VBA and Custom Forms 1
B VBA Help Email that will save as draft and send as attachment Outlook VBA and Custom Forms 3
K VBA to prompt and send a CC Outlook VBA and Custom Forms 6
N VBA Script to Send Automatic Emails from Outlook 2010 Outlook VBA and Custom Forms 1
D Outlook VBA to open Excel attachment and send recipient's email address to a workbook cell? Using Outlook 4
H Problems With Outlook 2013 VBA To Send and Print an email Outlook VBA and Custom Forms 1
D VBA Script (Ask to where to save send mail) Outlook VBA and Custom Forms 1
M VBA Send Sales reports using .oft files, originate in Outlook or Excel? Using Outlook 5
V "Accept + Send the Response now", VBA script? Using Outlook 1
D VBA: Send-From Code for Template Shortcut? Using Outlook 0
D Selection of Send-From Account with Template VBA Shortcut Using Outlook 0
L Send E-mail with VBA code from [E-mail Distribution Group] if I have “Send as” Using Outlook 6
S Outllok 2007 VBA code to send mail automatically from drafts folder Using Outlook 1
S Send All emails in Outbox and Quit using VBA Outlook VBA and Custom Forms 3
D Using VBA to send Word document as body of message works in 2007, but not in 2003 Outlook VBA and Custom Forms 9
H using VBA to edit subject line Outlook VBA and Custom Forms 0
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
Geldner Problem submitting SPAM using Outlook VBA Form Outlook VBA and Custom Forms 2
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
M Outlook 2016 outlook vba to look into shared mailbox Outlook VBA and Custom Forms 0
V VBA Categories unrelated to visible calendar and Visual appointment Categories Outlook VBA and Custom Forms 2
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 3
R Outlook 2019 VBA to List Meetings in Rooms Outlook VBA and Custom Forms 0
geoffnoakes Counting and/or listing fired reminders via VBA Using Outlook 1
O VBA - Regex - remove double line spacing Outlook VBA and Custom Forms 1
D.Moore Strange VBA error Outlook VBA and Custom Forms 4
B Modify VBA to create a RULE to block multiple messages Outlook VBA and Custom Forms 0
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
K vba code to auto download email into a specific folder in local hard disk as and when any new email arrives in Inbox/subfolder Outlook VBA and Custom Forms 0
D VBA - unable to set rule condition 'on this computer only' Outlook VBA and Custom Forms 5
L Fetch, edit and forward an email with VBA outlook Outlook VBA and Custom Forms 2
BartH VBA no longer working in Outlook Outlook VBA and Custom Forms 1
W Can vba(for outlook) do these 2 things or not? Outlook VBA and Custom Forms 2
MattC Changing the font of an email with VBA Outlook VBA and Custom Forms 1
P MailItem.To Property with VBA not work Outlook VBA and Custom Forms 2
P Tweak vba so it can target another mailbox Outlook VBA and Custom Forms 1
A Outlook 2010 VBA fails to launch Outlook VBA and Custom Forms 2
richardwing Outlook 365 VBA to access "Other Actions" menu for incoming emails in outlook Outlook VBA and Custom Forms 0
W Create a Quick Step or VBA to SAVE AS PDF in G:|Data|Client File Outlook VBA and Custom Forms 1
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
C Outlook (desktop app for Microsoft365) restarts every time I save my VBA? Using Outlook 1
D VBA Macro to Print and Save email to network location Outlook VBA and Custom Forms 1
TedSch Small vba to kill political email Outlook VBA and Custom Forms 3

Similar threads

Back
Top