In outlook…
CASE-1 : Selecting 'Test 2' & then select 'Test 1' => Reply/Reply-all buttons are enabled
CASE-2 : Selecting 'Test 1' & then select 'Test 2' => Reply/Reply-all buttons are disabled
I have Explorer.SelectionChange
event which checks if there are multiple emails are selected. If there are multiple emails are selected, Then I have disabled 'Reply/Reply-All' events by MailItem.Actions["Reply"].Enabled = false;
.
Explorer objExplorer = (Explorer)Api.Instance.GetActiveExplorer();
if (objExplorer != null)
{
objExplorer.SelectionChange += () =>
{
Selection objSelectionList = objExplorer.Selection;
if (objSelectionList != null && objSelectionList.Count > 1 && objSelectionList[1] != null)
{
MailItem objMailItem = objSelectionList[1] as MailItem;
if (objMailItem != null)
{
objMailItem.Actions["Reply"].Enabled = false;
objMailItem.Actions["Reply to All"].Enabled = false;
}
}
};
}
But it's not giving me output like CASE-2. So basically I want to make both buttons disabled in CASE-1 as shown in CASE-2. It's only giving me a popup saying 'This action not available for this item'.
I have to do this to maintain consistency in both case. So need solution from one of below..
Thanks in advance.
In the code you disable the Reply
and Reply to All
actions on the first selected item which is a different item in both scenarios:
MailItem objMailItem = objSelectionList[1] as MailItem;
if (objMailItem != null)
{
objMailItem.Actions["Reply"].Enabled = false;
objMailItem.Actions["Reply to All"].Enabled = false;
}
But the displayed item is always the same, but it is not necessary the first in the collection. So, instead I'd suggest iterating over all selected items and disabling actions for all of them to make sure the view is updated correctly. A raw sketch:
for(int i=1; i <= objSelectionList.Count; i++)
{
MailItem objMailItem = objSelectionList[i] as MailItem;
if (objMailItem != null)
{
objMailItem.Actions["Reply"].Enabled = false;
objMailItem.Actions["Reply to All"].Enabled = false;
}
}