.net 在Outlook VSTO加载项中,如何清除当前选择?

.net 在Outlook VSTO加载项中,如何清除当前选择?,.net,outlook,vsto,outlook-addin,.net,Outlook,Vsto,Outlook Addin,从Outlook VSTO加载项中,我要清除当前选择。 是否有用于此的API?我当前的黑客攻击它以临时选择已发送的文件夹 void ClearSelection(IRibbonControl control) { //Here be dragons //Ok this looks like pointless code but it is necessary. //For multiple items we are doing it in a background th

从Outlook VSTO加载项中,我要清除当前选择。
是否有用于此的API?

我当前的黑客攻击它以临时选择已发送的文件夹

void ClearSelection(IRibbonControl control)
{
    //Here be dragons
    //Ok this looks like pointless code but it is necessary. 
    //For multiple items we are doing it in a background thread. 
    //There is a "feature" in outlook that means you cant delete 
    //the current selected item from a background thread. 
    //So we need this to clear the selection
    //and NO "control.Explorer().ClearSelection();" does not work.
    var explorer = GetExplorer(control);
    var currentFolder = explorer.CurrentFolder;
    var session = ThisAddIn.Application.Session;
    var sentFolder = session.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
    explorer.CurrentFolder = sentFolder;
    explorer.CurrentFolder = currentFolder;
}

Explorer GetExplorer(IRibbonControl control)
{
    dynamic context = control.Context;
    var explorer = context.Parent as Explorer;
    if (explorer == null)
    {
        var application = (ApplicationClass)context.Parent;
        explorer = application.ActiveExplorer();
    }
    return explorer;
}

你知道怎么做了吗?@aloneguid不,我没有解决这个问题。我找到了如何清除所选内容的方法,这些内容足以满足我的目的。您是否清除所选内容?:)@我改变了问题并添加了一个答案:)它看起来很奇怪,但这和OL世界中的一切都一样,但它是有效的!谢谢