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

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
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
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
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
S Add VBA save code Using Outlook 0
C Auto Run VBA Code on new email Outlook VBA and Custom Forms 1
O VBA Cases with Listbox - Can you use Multi-Select? Outlook VBA and Custom Forms 4
O VBA Outlook Message Attachment - Array Index Out of Bounds Outlook VBA and Custom Forms 0
V Modifying the built in forms with VBA Outlook VBA and Custom Forms 4
S Excel VBA and shared calendar issue Outlook VBA and Custom Forms 4
L Macro/VBA to Reply All, with the original attachments Outlook VBA and Custom Forms 2
L VBA unknown character Outlook VBA and Custom Forms 2
G Move tasks up/down todo list by VBA Outlook VBA and Custom Forms 1
K Use VBA to find Sender and Recipient from Microsfot 365 Journaled Email Items Outlook VBA and Custom Forms 3
J Want to learn VBA Macros for Outlook. What book can you recommend? Outlook VBA and Custom Forms 2
F VBA code to dock Styles whenever I write or edit an email Outlook VBA and Custom Forms 0
C VBA to prompt for Sent folder destination Outlook VBA and Custom Forms 3
B Adding signature to bottom of VBA reply email Outlook VBA and Custom Forms 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
D.Moore VBA script fail after Office 365 update Using Outlook 8
R Limiting length of saved attachment in VBA Outlook VBA and Custom Forms 2
S Skype for business meeting vba code Outlook VBA and Custom Forms 1
C How to use VBA to show only items x days old or more Outlook VBA and Custom Forms 1
B VBA to convert email to task, insert text of email in task notes, and attach copy of original email Outlook VBA and Custom Forms 4
D Outlook VBA error extracting property data from GetRules collection Outlook VBA and Custom Forms 10
S Reference Custom Fields with VBA Outlook VBA and Custom Forms 2
O Email not leaving Outbox when using Excel VBA to sync Outlook account Outlook VBA and Custom Forms 4
G VBA Macro Calendar Printing Assistant 4
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
B VBA to Collapse Task Folder Groups Outlook VBA and Custom Forms 1
R Expand VBA Permanent Delete Code Outlook VBA and Custom Forms 6
shrydvd vba to secure zip attachments Outlook VBA and Custom Forms 3
M Adding Subject to this Link-Saving VBA Outlook VBA and Custom Forms 5

Similar threads

Top