VBA to send reminder email if no response

maheshbabu

Member
Best answers
0
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
Best answers
0
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.
 

Diane Poremsky

Senior Member
Best answers
0
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
can you post the code you are using?
 

maheshbabu

Member
Best answers
0
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
Best answers
0
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

Member
Best answers
0
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
Best answers
0
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
Best answers
0
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
Best answers
0
Outlook version
Outlook 2007
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
Best answers
0
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
Best answers
0
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
Best answers
0
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
Best answers
0
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
 
Top