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.
 

maheshbabu

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
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.
 

maheshbabu

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
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
 

maheshbabu

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
Hi,

Did you get a chance to look into the above scenario, if yes any update on the same.
 

Bamerand

Senior Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
I would be interested in reading the response from Diana, this is topic I was long time interested in...
 

greg

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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:

samita sarkar

New Member
Outlook version
Email Account
Exchange Server
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.
 

realozone

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 

realozone

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
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
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
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 0
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
E Outlook 365 Outlook/VBA Outlook VBA and Custom Forms 11
N VBA Macro To Save Emails Outlook VBA and Custom Forms 1
Z VBA Forward vs manual forward Outlook VBA and Custom Forms 2
J VBA Cannot programmatically input or change Value for User Defined field Using Outlook 1
J VBA for outlook to compare and sync between calendar Outlook VBA and Custom Forms 1
A Any way to force sort by/group by on search results with VBA? Outlook VBA and Custom Forms 1
E Default shape via VBA Outlook VBA and Custom Forms 4
Z Import Tasks from Access Using VBA including User Defined Fields Outlook VBA and Custom Forms 0
E Outlook VBA change GetDefaultFolder dynamically Outlook VBA and Custom Forms 6
justicefriends How to set a flag to follow up using VBA - for addressee in TO field Outlook VBA and Custom Forms 11
M add new attendee to existing meetings with VBA Outlook VBA and Custom Forms 5
D VBA code to select a signature from the signatures list Outlook VBA and Custom Forms 3
D Create advanced search (email) via VBA with LONG QUERY (>1024 char) Outlook VBA and Custom Forms 2
David McKay VBA to manually forward using odd options Outlook VBA and Custom Forms 1
FryW Need help modifying a VBA script for in coming emails to auto set custom reminder time Outlook VBA and Custom Forms 0
S vba outlook search string with special characters Outlook VBA and Custom Forms 1
S VBA search string with special characters Outlook VBA and Custom Forms 1
U Outlook 2019 VBA run-time error 424 Outlook VBA and Custom Forms 2
DDB VBA to Auto Insert Date and Time in the signature Outlook VBA and Custom Forms 2
F VBA to move email from Non Default folder to Sub folders as per details given in excel file Outlook VBA and Custom Forms 11
G VBA to save selected Outlook msg with new name in selected network Windows folder Outlook VBA and Custom Forms 1

Similar threads

Top