2012-04-18 29 views
2

OutlookアドインからmailItemを選択したいとします。 私はC#からメールアイテムを表示する方法を知っていますが、私はOutlookウィンドウ自体の中でそれを選択する必要があります。Outlookのメールアイテムの選択を変更するC#

表示mailitem:

mailItem.Display(); 

私はOutlook 2010のアドインを使用しています。

誰でもこれを行う方法はありますか?

答えて

4

Explorer.ClearSelection()を使用し、次にExplorer.AddToSelection()を使用します。 AddToSelection()を呼び出す前にExplorer.IsItemSelectableInView()を使用して、選択したい項目が現在のエクスプローラビューに存在することを確認してください。

Application.ActiveExplorer()が存在する場合は、現在のアクティブなエクスプローラが表示されます。

ここにはsample snippet taken from here)が少し修正されてIsItemSelectableInViewにチェックされています。

Outlook._Explorer explorer = OutlookApp.ActiveExplorer(); // get active explorer 
explorer.ClearSelection(); // remove current selection 
Outlook.NameSpace ns = OutlookApp.Session; 
object item = ns.GetItemFromID(entryId, Type.Missing); // retrieve item 
if (explorer.IsItemSelectableInView(item)) // ensure item is in current view 
    explorer.AddToSelection(item); // change explorer selection 
else 
    // TODO: change current view so that item is selectable 
Marshal.ReleaseComObject(item); 
Marshal.ReleaseComObject(ns); 
Marshal.ReleaseComObject(explorer); 

あなたがExplorer.CurrentFolderまたはExplorer.CurrentView

+1

甘い男:) THXを使用することができ、現在のExplorerビューを変更するには! (遅い応答ではsrrでしたが、他のものでは忙しかったです) – Zarkos

+0

会話ビューでApplication.ActiveExplorer()関数が機能しません – phuongnd

+0

ここからOutlookAppを取得していますか? –

関連する問題