VSTO 自定义文件夹类型

发布于 2024-12-25 08:53:20 字数 481 浏览 1 评论 0原文

是否可以使用 VSTO for Outlook 2007 创建自定义文件夹类型? (即类似于 olFolderContacts 等的新文件夹类型)

理想情况下,我想做的是拥有一个文件夹,选择该文件夹后,将在主 Outlook 窗口(收件箱和预览窗格所在的位置)中创建一个新的表单区域并显示 WPF 用户控件。

谢谢

类似:

在此处输入图像描述

我发现该图像同时试图解决此问题:http://www.add-in-express.com/add-in-net/outlook-regions-basics.php

Is it possible to create a custom folder type using VSTO for Outlook 2007? (i.e. a new folder type similar to olFolderContacts and so on)

Ideally what I would like to do is have a folder which, when selected, would create a new form region in the main Outlook window (where the Inbox and the Preview Pane are) and display a WPF User Control.

Thanks

Something like:

enter image description here

I found that image meanwhile trying to solve this question at: http://www.add-in-express.com/add-in-net/outlook-regions-basics.php

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

谁的新欢旧爱 2025-01-01 08:53:20

我能做的最接近的事情是:

  • 在 Outlook 上创建文件夹(我将其命名为登录):

  • 然后右键单击并设置其主页:

    在此处输入图像描述

  • 然后当我选择该文件夹或后面的代码时我可以选择它,我的前景如下:

    在此处输入图像描述

它将是如果我可以做同样的事情但使用 wpf 表单或自定义区域,那就太好了。现在我必须使用 websockets 或其他机制来与该控件进行事件通信。

The closest thing I have able to do is:

  • Create folder on outlook (I named it login):

  • Then right click and set its home page:

    enter image description here

  • then when I select that folder or on code behind I can select it my outlook looks like:

    enter image description here

It will be nice if I can do the same but with a wpf form or custom region. Now I have to use websockets or other mechanism to comunicate events with that control.

⒈起吃苦の倖褔 2025-01-01 08:53:20

由于 Outlook 使用 Internet Explorer 作为浏览器,因此您可以获得对 SilverLight 的本机支持。您是否可以将内容嵌入 SilverLight 网页,然后将其设置为文件夹的主页? WPF 和 SL 有很多共同点,所以也许这就是适合您的解决方案。

Since Outlook uses Internet Explorer as its browser, you get native support for SilverLight. Is there a chance you could embed your contents in a SilverLight webpage and then set that as your folder's home page? WPF and SL share a lot of common ground, so maybe this is a solution for you.

寂寞美少年 2025-01-01 08:53:20

找到了解决方案。唯一需要注意的是,我需要购买 VSTO 的高级 Outlook 区域 我花了 100 美元。如果您购买该产品,请按照以下方式操作:

1.在 Visual Studio 上创建一个类型为(Outlook 2010 加载项)的新项目,我将项目命名为 OutlookAddIn1

2.向项目添加新项目(我需要购买的产品)
在此处输入图像描述

3.当您选择该项目时,会出现一个向导,选择以下选项:
在此处输入图像描述

4.遵循所有默认值,直到向导完成(单击“下一步”、“下一步”等完成)

5.那里有一个 Windows 窗体。为了放置 WPF 内容,您需要添加 ElementHost 控件。有一个关于如何在 Windows 窗体上托管 wpf 用户控件的教程日志。为了不让这个答案保留那么久,我不会展示如何做。

6。为了演示这个答案,我将在该表单上放置一个按钮:
在此处输入图像描述

7.按下该按钮后,我将隐藏该表单并显示文件夹的默认视图。这是该按钮背后的代码:

    private void button1_Click(object sender, EventArgs e)
    {
        // disable the form that id does not show up
        Globals.ThisAddIn.ADXOlForm1Item.Enabled = false;

        // get the current selected folder
        var thisFOlder = Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder;

        // remove the webview pane in order to show the main folder view instead
        thisFOlder.WebViewOn = false;
        thisFOlder.WebViewURL = string.Empty;

        // RESET FOLDER BY SELECTING A DIFFERENT ONE THEN THE SAME ONE
        NameSpace nameSpace = Globals.ThisAddIn.Application.GetNamespace("MAPI");
        MAPIFolder outboxFolder = nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderOutbox);
        Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = outboxFolder; // CHANGE FOLDER TO A DIFFERNT ONE
        System.Windows.Forms.Application.DoEvents();
        Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = thisFOlder; // SET INBOX AGAIN

        // remeember to release objects
        Marshal.ReleaseComObject(nameSpace);
        Marshal.ReleaseComObject(outboxFolder);
        Marshal.ReleaseComObject(thisFOlder);

        this.Close();
    }

8。然后,当我运行该项目时,当我选择“邮件”类型的任何文件夹时看到:
在此处输入图像描述

9.如果我按下该按钮,我将显示我选择的文件夹的默认视图

我现在唯一的问题是该视图显示了 MailItem 类型的每个文件夹。您可以在第一个向导中选择不同的文件夹类型,这与 Jurnal 等不常见。然后,在代码后面,您可以选择要显示该表单的日记文件夹。

Found the solution. The only caveat is that I need to purchase Advanced Outlook regions for VSTO and it cost me 100 dollars. If you purchase that product this is how you do it:

1. Create a new project on vistual studio of type (Outlook 2010 Add-in) I named my project OutlookAddIn1

2. Add a new item to the project (Product that I needed to purchase)
enter image description here

3. When you select that item a wizard shows up select the following options:
enter image description here

4. Follow all the defaults until the wizard finishes (click next, next etc. finish)

5. There you have a windows forms. In order to place WPF content you will need to add a ElementHost controls. There are a log of tutorials on how to host a wpf usercontrol on windows forms. To keep this answer not that long I will not show how.

6. For demo of this answer I will just place a button on that form:
enter image description here

7. with the press of that button I will hide that form and show the deffault view of the folder. So here is the code behind of that button:

    private void button1_Click(object sender, EventArgs e)
    {
        // disable the form that id does not show up
        Globals.ThisAddIn.ADXOlForm1Item.Enabled = false;

        // get the current selected folder
        var thisFOlder = Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder;

        // remove the webview pane in order to show the main folder view instead
        thisFOlder.WebViewOn = false;
        thisFOlder.WebViewURL = string.Empty;

        // RESET FOLDER BY SELECTING A DIFFERENT ONE THEN THE SAME ONE
        NameSpace nameSpace = Globals.ThisAddIn.Application.GetNamespace("MAPI");
        MAPIFolder outboxFolder = nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderOutbox);
        Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = outboxFolder; // CHANGE FOLDER TO A DIFFERNT ONE
        System.Windows.Forms.Application.DoEvents();
        Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = thisFOlder; // SET INBOX AGAIN

        // remeember to release objects
        Marshal.ReleaseComObject(nameSpace);
        Marshal.ReleaseComObject(outboxFolder);
        Marshal.ReleaseComObject(thisFOlder);

        this.Close();
    }

8. When I then run that project note when I see when selecting any folder of type Mail:
enter image description here

9. If I press that button I will then show the default view of the folder I had selected

The only probelm that I have now is that the view shows for every folder of type MailItem. You could select a different folder type on the first wizzard something that is not that common like Jurnal. Then on code behind you can select a jurnal folder for that form to show up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文