从Outlook 2010中的选定邮件项目中获取信息 [英] Getting info from selected mail item in Outlook 2010
问题描述
我想为Outlook 2010写一个加载项.想法是-用户在文件夹中选择一个邮件项目,然后按功能区上的按钮启动加载项.加载项从选定的项目获取信息,对其进行处理并显示结果. 尝试获取所选项目的检查器时遇到问题.我试过了:
I want to write an add-in for Outlook 2010. The idea is - user selects one mail item in folder, then presses the button on ribbon which starts the add-in. Add-in gets information from selected item, process it and displays result. I run in to problems when trying to get the Inspector of selected item. I tried:
Outlook.Inspector Point = this.Application.ActiveInspector().CurrentItem as Outlook.Inspector;
Outlook.MailItem mailItem = Point.CurrentItem as Outlook.MailItem;
当然,这不会检查当前项目是否实际上是邮件项目,但这是供以后使用的.我的问题是,当我尝试运行该程序时,我得到了NullReferenceException. 我在网上发现的唯一可行示例是使用事件处理.但是我想在按钮按下时开始加载..
Of course this doesn't check if current item is actually an mail item but that's for later. My problem is, when i try running the program i get NullReferenceException. The only working examples of this I found on web was with event handling. But I want to start add-in on button press..
我试图在.NET 3.5而不是4中做到这一点
I am trying to make this in .NET 3.5 not 4
推荐答案
c0> 是用户双击 MailItems
-您将没有活动的检查器窗口(因此是NullReferenceException
).
The ActiveInspector()
is the window that opens when the user double-clicks a mail item in the Explorer
window. If the user is just viewing MailItems
in the reading pane - you won't have an active inspector window (hence the NullReferenceException
).
您可能正在寻找 Explorer.Selection
以获取访问权限到当前选择的 MailItems
.
You are probably looking for the Explorer.Selection
to get access to the currently selected MailItems
.
Outlook.Selection selection = this.Application.ActiveExplorer().Selection;
这篇关于从Outlook 2010中的选定邮件项目中获取信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!