Reply all intercept Outlook 2010

Status
Not open for further replies.

markyy

Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server 2010
So I am an intern with very little VB experience, but my employer has tasked me with *attempting* to find or create a macro to intercept the reply all action to prompt a dialog box with options for "Yes" and "No". I found a few scripts that are similar to what we need the majority did not work at all, though the one posted at http://www.outlookcode.com/codedetail.aspx?id=1299 prompted the dialog box. It did so on both reply and reply all. If you choose the "no" option in that script it brings you to the message replying to the sender (Which I along with a few on my team like) BUT management wants it to basically do nothing if you say no. The script that I have now is an edited version of the script posted in the link above. Could anyone steer me in the right direction with this? Or link me to a script that is known to work?

Thanks.


Dim WithEvents colInsp As Outlook.Inspectors
Dim WithEvents msg As Outlook.mailItem
Dim replyAll As Boolean
Dim oLook As Outlook.Application

Private Sub Application_Startup()
Set colInsp = Application.Inspectors

End Sub

Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)

Dim mymsg As String
Dim myResult As Integer
Dim count As Integer
Dim i As Integer
On Error Resume Next

If TypeOf Inspector.CurrentItem Is Outlook.mailItem Then


Set msg = Inspector.CurrentItem
' check if new item
If msg.Size = 0 Then
' check if replyall
If msg.Recipients.count > 1 Then
mymsg = "Do you really want to reply to all original recipients?"
myResult = MsgBox(mymsg, vbYesNo, "Flame Protector")
If myResult = vbNo Then
' remove all recipients except the first one


replyAll = False


'count = msg.Recipients.count
'For i = count To 2 Step -1
' msg.Recipients.Remove i
'Next
End If
End If
End If
Set msg = Nothing
End If
End Sub

Private Sub msg_Open(Cancel As Boolean)
If replyAll = False Then
Cancel = True
End If
End Sub

Private Sub msg_ReplyAll(ByVal Response As Object, Cancel As Boolean)
If replyAll = False Then
Cancel = True
End If
End Sub
 

markyy

Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server 2010
Sorry I didnt have the code in this format in the first post.


Code:
Dim WithEvents colInsp As Outlook.Inspectors
Dim WithEvents msg As Outlook.mailItem
Dim replyAll As Boolean
Dim oLook As Outlook.Application

Private Sub Application_Startup()
    Set colInsp = Application.Inspectors
   
End Sub

Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
   
    Dim mymsg As String
    Dim myResult As Integer
    Dim count As Integer
    Dim i As Integer
    On Error Resume Next
    
    If TypeOf Inspector.CurrentItem Is Outlook.mailItem Then

   
        Set msg = Inspector.CurrentItem
        ' check if new item
        If msg.Size = 0 Then
            ' check if replyall
            If msg.Recipients.count > 1 Then
                mymsg = "Do you really want to reply to all original recipients?"
                myResult = MsgBox(mymsg, vbYesNo, "Flame Protector")
                If myResult = vbNo Then
                    ' remove all recipients except the first one
                  
                  
               replyAll = False

                                       
                    'count = msg.Recipients.count
                    'For i = count To 2 Step -1
                     '   msg.Recipients.Remove i
                    'Next
                End If
            End If
        End If
        Set msg = Nothing
    End If
End Sub

Private Sub msg_Open(Cancel As Boolean)
If replyAll = False Then
Cancel = True
End If
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
That seems like a lot of code just to check when the Replyall button is clicked. The code from outlookcode.com checks the recipient count on the message after it opens (that is the NewInspector), so it's going to leave the compose message open. This one traps the ReplyAll button click and lets you cancel it.
Code:
Option Explicit
Private WithEvents oExpl As Explorer
Private WithEvents oItem As MailItem
Dim oResponse As MailItem
Dim myAddy As String
Private bDiscardEvents As Boolean


Private Sub Application_Startup()
  Set oExpl = Application.ActiveExplorer
  bDiscardEvents = False
End Sub

Private Sub oExpl_SelectionChange()
  On Error Resume Next
  Set oItem = oExpl.Selection.Item(1)
End Sub

Private Sub oItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
 
  If MsgBox("Are you sure you want to reply to all of the senders of this message?" _
  , vbYesNo + vbQuestion, "Confirm Reply To All") = vbNo Then
  Cancel = True
  End If
End Sub
 

markyy

Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server 2010
That seems like a lot of code just to check when the Replyall button is clicked. The code from outlookcode.com checks the recipient count on the message after it opens (that is the NewInspector), so it's going to leave the compose message open. This one traps the ReplyAll button click and lets you cancel it.
Code:
Option Explicit
Private WithEvents oExpl As Explorer
Private WithEvents oItem As MailItem
Dim oResponse As MailItem
Dim myAddy As String
Private bDiscardEvents As Boolean


Private Sub Application_Startup()
  Set oExpl = Application.ActiveExplorer
  bDiscardEvents = False
End Sub

Private Sub oExpl_SelectionChange()
  On Error Resume Next
  Set oItem = oExpl.Selection.Item(1)
End Sub

Private Sub oItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)

  If MsgBox("Are you sure you want to reply to all of the senders of this message?" _
  , vbYesNo + vbQuestion, "Confirm Reply To All") = vbNo Then
  Cancel = True
  End If
End Sub

Awesome this worked great!! Now is there a way to distribute this to other machines? I tried sending over "ThisOutlookSession.cls" But that did not work. I also looked into using Visual Studio to create a com-Addin, but I feel like that is putting myself in way over my head. Like I said I am very new to all of this so every bit of help I get is awesome. Thanks again Diane!
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Outlook VBA is not easy to deploy. You can distribute the entire project file (*.otm), which would replace an existing project file, though. Deploying a single file works, too, you just need to import it manually.

BTW: There's one situation where the shown code doesn't work. If you right click on a message in the folder view that's not selected already, then the SelectionChange event doesn't trigger (which I consider a bug), thus you won't reveive the item's events.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You can't install macros automatically - but you can send everyone a text file with the code and instructions to set it up.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
ThinkToday Calculate reply time of outlook mail Using Outlook 1
W Replyin to the reply-to email address Outlook VBA and Custom Forms 0
D Reply with a template loose the sender's embedded image Outlook VBA and Custom Forms 0
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
J Outlook Reply > From > Other Email Address... > Address Not Showing in Sent Items... From Email Outlook VBA and Custom Forms 0
M Delete headers in Inline reply Outlook VBA and Custom Forms 5
E reply Using Outlook 0
Healy Consultants Macro to remove inside organization distribution list email address when reply to all recepients Outlook VBA and Custom Forms 0
B resend if no reply and send an automatic reminder Outlook VBA and Custom Forms 0
evdbogaard Reply with only last message cited Using Outlook 1
B Reply and replyall macro is not working Outlook VBA and Custom Forms 1
mctabish Setting "Reply To" based on inbox Outlook VBA and Custom Forms 2
Rupert Dragwater Deleted email address keeps showing up in reply Using Outlook 12
B When working on emails in a certain folder, when I hit reply or reply all, I would like it re always reply all and add an email address to send to Outlook VBA and Custom Forms 3
R How Do I insert images in and Auto Reply Using Outlook 3
D Disable or hide "reply" and "reply to all" and "forward" in email from access vba Outlook VBA and Custom Forms 1
M Reply Inline With a Outlook Template Outlook VBA and Custom Forms 6
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
O On click,I want to change subject line of selected mail and then reply to particular email and move Using Outlook 3
J VBA Run When Reply Outlook VBA and Custom Forms 4
D Font in Reply is much larger than normal, how to reset ...? Using Outlook 4
K add pdf to every reply or forward Outlook VBA and Custom Forms 1
A VB to "reply all" email items stored in a folder of outlook with adding a new message Outlook VBA and Custom Forms 0
K Extract email address from body and auto-reply outlook Using Outlook 1
T In-line reply style in Outlook Outlook VBA and Custom Forms 20
Vijay Reply all by attachment name Using Outlook 10
N Lookup Value From Excel and Reply With Matching Value Using Outlook 0
G Outlook 2016: reply icon not showing when replied from mobile Using Outlook 3
J Remove extra line above signature in reply Outlook VBA and Custom Forms 5
ashcosta2 Auto Reply rule based on speficied time Outlook VBA and Custom Forms 0
C Outlook Attachment List in Reply Header Using Outlook 3
D Reply Problem with Outlook.com account Using Outlook.com accounts in Outlook 0
H send reminder if no reply received on first or original email using macro Using Outlook 2
Diane Poremsky Reply to All Includes My Address New Slipstick.com Articles 0
F Room Mailbox Reply Exchange Server Administration 0
N How to add Dear & mail receipts name while reply to that mail in outlook2007 Outlook VBA and Custom Forms 1
J Force account selection for sending reply emails Using Outlook 1
J Adding Reply & Delete to main toolbar? Using Outlook 0
Diane Poremsky Outlook Crashes When You Reply or Create a New Message New Slipstick.com Articles 0
S Outlook Macro Reply to a message Outlook VBA and Custom Forms 1
D Automatically file message and reply to folder. Using Outlook 1
O Reply and Add CC Outlook VBA and Custom Forms 4
S Default Calendar Reply Addresses Using Outlook 2
Fabio Quintal Reply All no longer working Using Outlook 9
Diane Poremsky Reply or ReplyAll with Attachments New Slipstick.com Articles 0
Diane Poremsky Remove an Address from Reply All New Slipstick.com Articles 0
S Reply & Forward Date in original message incorrect Using Outlook 2
J Pull an email address from body and replace reply-to address Outlook VBA and Custom Forms 4
wallisellener Unable to reply/post/create new thread using Chrome BCM (Business Contact Manager) 5
R Reply marks read message as unread Using Outlook 1
Similar threads


















































Top