简体   繁体   English

用于过滤收件人的 Outlook 插件

[英]Outlook AddIn for filtering recipients

I want to build an Outlook AddIn in C# that has a button in the calendar ribbon that the user clicks to create a new meeting with one of their employees.我想在 C# 中构建一个 Outlook 插件,它在日历功能区中有一个按钮,用户单击该按钮可以创建与其中一名员工的新会议。 We want the user (the manager) to be able to select the employee from a filtered list of only their own employees and not have to search through the entire directory.我们希望用户(经理)能够从过滤后的员工列表中选择员工,而不必搜索整个目录。 What is the best way to do this?做这个的最好方式是什么?

addendum: I did some searching and I came across a potential method for the filter.附录:我进行了一些搜索,发现了一种潜在的过滤器方法。

I know that the "SelectNamesDialog" function will get me an Address Book dialog box:我知道“SelectNamesDialog”函数会给我一个地址簿对话框:

Outlook.SelectNamesDialog snd = Application.Session.GetSelectNamesDialog();

I want to combine that with a piece of code I found.我想将它与我找到的一段代码结合起来。 I modified it to return the names of all the manager's direct reports (the employees under the manager).我修改了它以返回所有经理的直接下属(经理下属的员工)的姓名。

I think I'm on the right track, but I'm uncertain of what to do next.我认为我在正确的轨道上,但我不确定下一步该怎么做。 How do I now allow the user to select one of these names through the GetSelectNamesDialog?我现在如何允许用户通过 GetSelectNamesDialog 选择这些名称之一? It is OK if your answer is in psuedocode.如果您的答案是伪代码,则可以。

// source: "How to: Get Information About Direct Reports of the Current User's Manager" 
// https://msdn.microsoft.com/en-us/library/ff184617.aspx
        private List<string> GetManagerDirectReports()
        {
            List<string> AddressNames = new List<string>();

            Outlook.AddressEntry currentUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry;
            if (currentUser.Type == "EX")
            {
                Outlook.ExchangeUser manager = currentUser.GetExchangeUser().GetExchangeUserManager();
                if (manager != null)
                {
                    Outlook.AddressEntries addrEntries = manager.GetDirectReports();
                    if (addrEntries != null)
                    {
                        foreach (Outlook.AddressEntry addrEntry in addrEntries)
                        {
                            //System.Windows.Forms.MessageBox.Show(addrEntry.Name);
                            AddressNames.Add(addrEntry.Name);
                        }
                    }
                }
            }
            return AddressNames;
        }

地址簿不会让您将列表限制为某些用户的子集,因此您需要提供自己的窗口,提示用户从预先过滤的列表中进行选择。

I now seem to be able to post an answer to my own question.我现在似乎可以发布我自己问题的答案。

I added a dropdown in the Form Region and added this code to populate the dropdown with names of the manager's direct reports:我在表单区域中添加了一个下拉列表,并添加了此代码以使用经理的直接下属的姓名填充下拉列表:

// Get Outlook list of employees who report to manager, using Exchange data.
List<string> mgrAddressNames = GetManagerDirectReports();

if (mgrAddressNames.Count >= 1)
{
   try
   {
    // System.Windows.Forms.BindingSource bindingSource1;
    // Create a Binding Source to the ComboBox to make values in ComboBox match the results of the list of direct reports.
    System.Windows.Forms.BindingSource bindingSource1 = new System.Windows.Forms.BindingSource();
    bindingSource1.DataSource = mgrAddressNames;
    EmployeeInvited.DisplayMember = "Value";
    EmployeeInvited.ValueMember = "Key";
    EmployeeInvited.DataSource = bindingSource1.DataSource;

    bindingSource1.Dispose();

(etc)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM