Using Events with Automation explique comment utiliser Outlook Events avec Automation. Je ne comprends pas cependant comment implémenter ce code dans mon projet.Utilisation des événements Outlook avec l'automatisation
Je veux utiliser la méthode InspectorBeforeMinimizeEvent
comme expliqué dans Inspector.BeforeMinimize Event (Outlook)
Chaque fois que l'utilisateur se déplace/redimensionne/maximise/minimise l'inspecteur manuellement puis le MessageBox
devrait apparaître.
code suivant pour les tests:
Imports Microsoft.Office.Interop
Public Class Form1
Public WithEvents myIns As Outlook.Inspector
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Process.Start("Outlook.exe")
Threading.Thread.Sleep(3000)
Dim olApp As New Outlook.Application
Dim myMailItem As Outlook.MailItem
myMailItem = CType(olApp.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem)
myMailItem.Subject = "Hello"
myMailItem.To = "[email protected]"
myMailItem.Body = "Hi there..."
Dim myIns As Outlook.Inspector
myIns = myMailItem.GetInspector
myIns.Display(False)
Dim myWord As Word.Document
myWord = CType(myIns.WordEditor, Word.Document)
Dim mySel As Word.Selection
mySel = myWord.Application.Selection
Threading.Thread.Sleep(10000)
'Following line just for testing. Normally following line doesnt exist in my original code. The real scenario is the user minimizes the inspector manually.
myIns.WindowState = Outlook.OlWindowState.olMinimized
myWord.InlineShapes.AddPicture(FileName:="C:\Example.png", LinkToFile:=False, SaveWithDocument:=True, Range:=mySel.GoTo(What:=Word.WdGoToItem.wdGoToLine, Which:=Word.WdGoToDirection.wdGoToLast, Count:=-4))
'myMailItem.Send()
End Sub
End Class
Code de l'événement:
Private Sub myIns_BeforeMinimize(Cancel As Boolean)
MessageBox.Show("You are minimizing this inspector.", "Title", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
End Sub
S'il vous plaît ne pas vandaliser vos messages. En postant sur le réseau Stack Exchange, vous avez accordé un droit non révocable à SE de distribuer ce contenu (sous la licence [CC BY-SA 3.0] (https://creativecommons.org/licenses/by-sa/3.0 /)). Par la politique de SE, tout vandalisme sera annulé. Si vous souhaitez dissocier ce message de votre compte, voir [Quel est le chemin approprié pour une demande de dissociation?] (Https://meta.stackoverflow.com/q/323395) – Bugs