我正在开发 Outlook VSTO 插件。
我(未成功)尝试自定义右键单击电子邮件的内容时出现的上下文菜单。请注意,大多数在线可用资源(例如this,否则就很棒)解释了如何自定义当您单击邮箱中的电子邮件项目时显示的上下文菜单 - 而不是当您右键单击内容时显示电子邮件本身。
我已经阅读了数十个主题...但到目前为止未能找到提示。
到目前为止,我最好的尝试是检索检查器中的 WordEditor 并尝试访问此 WordEditor 的命令栏。但这不起作用...我很乐意与任何人讨论解决方法/其他方法/相关资源:)
Imports System.Diagnostics
' So that we can have intellisense in the WordEditor object
Imports System.Runtime.InteropServices
Public Class ThisAddIn
Private Sub ThisAddIn_Startup() Handles Me.Startup
' Whenever a new inspector is created, let's see if we can customize its menus
AddHandler Globals.ThisAddIn.Application.Explorers.NewExplorer, AddressOf OnNewExplorer
End Sub
Private Sub OnNewInspector(inspect As Microsoft.Office.Interop.Outlook.Inspector)
If inspect IsNot Nothing Then
' WordEditors are only located in inspectors that have IsWordMail = true
If inspect.IsWordMail Then
' ... and that have the EditorType = olEditorWord
If inspect.EditorType = Microsoft.Office.Interop.Outlook.OlEditorType.olEditorWord Then
Try
' Get the WordEditor that is in the email
' Always fails here - as if by the time that OnNewInspector is called, the WordEditor was not available yet
Dim doc As Microsoft.Office.Interop.Word.Document = inspect.WordEditor()
' Get the right command bar (still to confirm, seen in online forums)
cb = doc.CommandBars("Text")
If cb IsNot Nothing Then
Dim cbCtrl As Microsoft.Office.Core.CommandBarControl
'... add a new button to the command bar
End If
' Release COM objects from memory
Marshal.ReleaseComObject(doc)
Catch ex As Exception
' This code always ends up here
Debug.WriteLine("exception:" & ex.Message)
End Try
Else
Debug.WriteLine("This inspector does not have the right Editor Type")
End If
Else
Debug.WriteLine("This inspector is not a WordMail")
End If
End If
End Sub
最好 - 再次感谢您的帮助,
JB
阅读窗格弹出菜单来自Word(Outlook 使用Word-light 来显示和编辑消息)。我认为您无法自定义它。