Developing an Outlook 2010 add-in to capture the Reply All functionality, giving the user a prompt and opportunity to back out. The code I have (included) is close but not quite there. Hopefully someone can help. There are three ways to Reply All to a message. You can click the Reply All button from Office Ribbon, you can right-click on the message and choose Reply All, or you can hit Reply All from in the opened message itself. The code I've written works. Sort of. If you right-click the message it always works, but any of the other methods only work after you've opened the message.
I'm clearly not capturing all of the events I need to, and possibly in not in the proper way too. Any advice, suggestions or help would be greatly appreciated. Thanks!
I'm clearly not capturing all of the events I need to, and possibly in not in the proper way too. Any advice, suggestions or help would be greatly appreciated. Thanks!
VB.NET:
Imports Microsoft.Office.Interop.Outlook
Public Class ThisAddIn
Public WithEvents olkEx As Outlook.Explorer
Public WithEvents olkMailItem As Outlook.MailItem
Public WithEvents olkExplorers As Outlook.Explorers
Private Sub ThisAddIn_Startup() Handles Me.Startup
Dim myOL As Outlook.Application
myOL = Globals.ThisAddIn.Application
olkEx = myOL.ActiveExplorer
olkMailItem = olkEx.Selection.Item(1)
End Sub
Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
End Sub
Private Sub olkEx_Activate() Handles olkEx.Activate
If olkEx.Selection.Count > 0 Then
olkMailItem = olkEx.Selection.Item(1)
End If
End Sub
Private Sub olkMailItem_ReplyAll(ByVal Response As Object, ByRef Cancel As Boolean) Handles olkMailItem.ReplyAll
If olkMailItem.Class = Outlook.OlObjectClass.olMail Then
If MsgBox("Are you sure you want to Reply To All?", _
vbQuestion + vbYesNo, "Verify Reply to All (M&G)") = vbNo Then
Cancel = True
End If
End If
End Sub
End Class