Outlook 2010 oft template Item_Send not firing

0

I have written a very simple Item_Send handler for an outlook mail message template stored as an oft file that I run via a Macro:

Function Item_Send()
    MsgBox "hello"
    Item_Send = False
End Function

This event is not firing: I see no message box and the message sends.

Can anyone explain why this would be and how I can fix it?

user1911388

Posted 2014-12-29T20:23:10.497

Reputation: 213

Answers

0

The code fails to work because it is not configured correctly to tie in to the built-in Outlook event-handling system. The below code and description, copied directly from the "Example" section on this page1, provides a template for implementing custom code in response to sending a mail item.

The following Microsoft Visual Basic for Applications (VBA) example shows how to cancel the ItemSend event in response to user input. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Outlook.

Public WithEvents myOlApp As Outlook.Application 
Public Sub Initialize_handler() 

Set myOlApp = Outlook.Application 

End Sub 


Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean) 
Dim prompt As String 

prompt = "Are you sure you want to send " & Item.Subject & "?" 

If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo 
    Cancel = True 
End If 

End Sub

1 http://msdn.microsoft.com/en-us/library/office/ff865076%28v=office.15%29.aspx

hBy2Py

Posted 2014-12-29T20:23:10.497

Reputation: 2 123