如何以编程方式打开Outlook快捷方式

时间:2012-06-12 12:11:02

标签: vb.net outlook vsto add-in

我想知道是否有一种方法可以从我的插件中以编程方式打开Outlook快捷方式。

我创建了如下的快捷方式

Sub AddShortcut()
    Dim myOlBar As Outlook.OutlookBarPane
    Dim myolGroup As Outlook.OutlookBarGroup
    Dim myOlShortcuts As Outlook.OutlookBarShortcuts

    myOlBar = Application.ActiveExplorer.panes.Item("OutlookBar")
    myolGroup = myOlBar.Contents.Groups.Item(1)
    myOlShortcuts = myolGroup.Shortcuts
    myOlShortcuts.Add("http://microsoft.com/", _
    "MSHomepage", 1)
End Sub

我猜我需要以某种方式使用InvokeMember

myOlShortcuts("MSHomepage").GetType().InvokeMember(..) 

但是当我使用GetType().GetMethods()时,我看不到任何Click成员或类似内容。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

如果您想要trigger the Outlook integrated web browser,则应抓住OutlookBarShortcut.Target。如果目标的类型为string,请使用以下内容(将您的目标替换为地址文本)...

Office.CommandBarComboBox address = (Office.CommandBarComboBox)Application.ActiveExplorer().CommandBars.FindControl(26, 1740);
address.Text = "http://www.stackoverflow.com";

否则类型为Folder,您应该指定Explorer.CurrentFolder。这种方法唯一的缺点是CommandBars have been deprecated with Outlook 2010,这个解决方案可能不适用于下一版本的Office。

另一种方法是使用Web Folder behavior as discussed in this SO post。您可以创建一个仅用于导航目的的隐藏Folder