like in the headline I want to open a Form via a Button in the Ribbon of Outlook. This Form contains the MailBody of the selected Mail and some DropDown Fields. When you click on 'Send' there should pop up a MsgBox wich is defined in ThisOutlookSession, but it does not work. When I open the Form manually with the 'Choose Form', it works. Is this a bug, or is there any workaround? Thank you in advance and please ask if anything is not clear.
I use VBA. Under Project1 in ThisOutlookSession I have got following Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
MsgBox ("Hallo")
End Sub
The Form is stored/published under private forms library and is called from a module with the following code:
Set cstmControls = otlMAPIFolder.Items.Add("IPM.Note.Formular3")
But when I click the Send Button of the Ribbon the MsgBox does not appear.
The full Code of the Module, which calls the Form:
Option Explicit
Public otlAppl As Outlook.Application
Public otlMAPINameSpace As NameSpace
Public otlMAPIFolder As MAPIFolder
Public otlMailItem As MailItem
Public cstmControls As MailItem
Public cstmUprop As UserProperties
Sub FormSend()
Set otlAppl = CreateObject("Outlook.Application")
Set otlMAPINameSpace = otlAppl.GetNamespace("MAPI")
Set otlMAPIFolder = otlMAPINameSpace.GetDefaultFolder(olFolderInbox)
Set otlMailItem = ActiveExplorer.Selection.Item(1)
Set cstmControls = otlMAPIFolder.Items.Add("IPM.Note.Formular3")
Set cstmUprop = cstmControls.UserProperties
'Body
Dim strBody As String
strBody = otlMailItem.Body
'Recipient
Dim strTo As String
strTo = otlMailItem.SenderEmailAddress
strBody = strBody
With cstmControls
.To = strTo
.Body = strBody
.Display True
End With
End Sub