运行Outlook加载项的启动任务而无需禁用

发布于 2025-02-11 17:03:38 字数 759 浏览 1 评论 0原文

我正在为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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

累赘 2025-02-18 17:03:38

,也许还有更多,例如初始化Azure Services。

启动活动厂商并不是这样做的最佳场所。

有解决方法吗?喜欢,使用Web加载项?我正在使用VSTO加载项。

Web附加组件不是为处理传入的电子邮件而设计的。他们仅在当前选择的项目的背景下工作。

或我可以用来进行初始化的其他延迟启动回调?

您可以使用在主线程上触发tick事件的计时器。例如,看看计时器类来自System.windows.forms namespace。

And maybe more, like initializing Azure services.

The startup event handers are not the best place for such things.

Is there a workaround? Like, using Web Add-in? I'm using VSTO Add-in.

Web add-ins are not designed for handling incoming emails. They work under the context of currently selected item only.

Or there are other delayed startup callbacks that I can use to do initialize?

You can use a timer which fires the Tick event on the main thread. For example, take a look at the Timer Class from the System.Windows.Forms namespace.

谢绝鈎搭 2025-02-18 17:03:38
  1. 发布项目,使用版本不会看到该问题。
  2. 避免在OneDrive同步文件夹中设置项目。
  3. 如果您需要调试,调试可能会导致高启动延迟可以使您的加载项禁用。只是强迫在开发阶段实现几天。
  1. Publish the project, use release version won't see the issue.
  2. Avoid setup project in OneDrive syncing folder.
  3. If you need to debug, debugging can cause high startup latency can make your Add-in disabled. Just force enabling it for a few days during development stage.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文