运行Outlook加载项的启动任务而无需禁用
我正在为Outlook写一个加载项。
我需要执行这样的启动任务:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
outlookNameSpace = this.Application.GetNamespace("MAPI");
inbox = outlookNameSpace.GetDefaultFolder(
Microsoft.Office.Interop.Outlook.
OlDefaultFolders.olFolderInbox);
items = inbox.Items;
items.ItemAdd +=
new Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd);
}
也许还有更多,例如初始化Azure Services。
但是加载项一次又一次地被禁用。给出的原因是启动时间中代码的延迟。
我知道我们可以强迫它不是禁用的。 但是请用户这样做是不人道的。
有解决方法吗? 喜欢,使用Web加载项?我正在使用VSTO加载项。
还是我可以使用其他延迟的启动回调来进行初始化?
还是使用Ontimer回电?但是看起来错误。
还是在启动功能中创建任务?也不是很成功。
有什么想法吗?谢谢。
I'm writing an Add-in for Outlook.
I need to run some start up task like this:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
outlookNameSpace = this.Application.GetNamespace("MAPI");
inbox = outlookNameSpace.GetDefaultFolder(
Microsoft.Office.Interop.Outlook.
OlDefaultFolders.olFolderInbox);
items = inbox.Items;
items.ItemAdd +=
new Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd);
}
And maybe more, like initializing Azure services.
But The Add-in is disabled again and again. The cause given is latency of code in startup time.
I know we can force it not disabled.
But ask user to do that is inhuman.
Is there a workaround?
Like, using Web Add-in? I'm using VSTO Add-in.
Or there are other delayed startup callbacks that I can use to do initialize?
Or Use OnTimer call back? But looks giving errors.
Or create a Task in Startup function? Also not very successful.
Any ideas? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
启动活动厂商并不是这样做的最佳场所。
Web附加组件不是为处理传入的电子邮件而设计的。他们仅在当前选择的项目的背景下工作。
您可以使用在主线程上触发
tick
事件的计时器。例如,看看计时器类来自System.windows.forms
namespace。The startup event handers are not the best place for such things.
Web add-ins are not designed for handling incoming emails. They work under the context of currently selected item only.
You can use a timer which fires the
Tick
event on the main thread. For example, take a look at the Timer Class from theSystem.Windows.Forms
namespace.