Handling Reply All on messages in Sent Items folder has unwanted and unexpected behavior

Add-in Express™ Support Service
That's what is more important than anything else

Handling Reply All on messages in Sent Items folder has unwanted and unexpected behavior
When I handle Reply All in messages in Sent Items folder, I'm getting unwanted and unexpected behavior 
Roberto Esguerra




Posts: 22
Joined: 2022-01-31
Andrei,

I've been developing an Outlook add-in to handle Reply All (there's other functionality, but this is the primary goal). Essentially, if the number of individuals in the recipients exceeds a threshold, the user is prompted with a Yes/No dialog: Yes means they continue with the Reply All message, No means it's canceled. I've run into new issues, and your replies to previous topics have been helpful, so I'm back!

Handling Reply All to messages in my Inbox works as expected. But when the same code is used for messages in the Sent Items folder, I get unwanted and unexpected behavior:

  • right-click on message, select Reply All, select Yes in the Y/N dialog, but no Reply All message appears
  • select a message, click Reply All in the Respond main toolbar (and only here), select Yes in the Y/N dialog, and and the Y/N dialog appears again


I have code in the add-in event handlers adxOutlookEvents_InspectorActivate and adxOutlookAppEvents_ExplorerSelectionChange to connect any mail item to the item events class. I also have code in the add-in event handler adxRibbonCommand_OnAction, to handle the right-click Reply All.

I override the event handler ProcessReplyAll in the item events class, which calls code in a custom object that does the actual Reply All handling. This same custom object code is also called in adxRibbonCommand_OnAction.

I'm hoping this is a simple fix related to the messages being located in the Sent Items folder. What do I need to do?

Robert
Posted 12 Jul, 2022 01:52:18 Top
Andrei Smolin


Add-in Express team


Posts: 18816
Joined: 2006-05-11
Hello Robert,

I've never seen the threshold. As to the issue, does your code by any chance change the item which is being replied?

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 12 Jul, 2022 03:43:52 Top
Roberto Esguerra




Posts: 22
Joined: 2022-01-31
Andrei,

Sorry, I wasn't clear. The threshold is something I set - for example, 15 individuals among the recipients.

My code is not changing the item which is being replied to.

I've discovered that if I comment out all the code in the adxRibbonCommand_OnAction event handler, all the issues disappear. Reply All works in both the inbox folder and the Sent Items folder, whether I use Reply All in the Respond section, Reply All inline, or Reply All in an Inspector window. Of course, with an empty adxRibbonCommand_OnAction, I am not trapping Reply All in the right-click popup menu.

Here is the skeleton of my (commented out) code in adxRibbonCommand_OnAction:


private void adxRibbonCommand_OnAction(object sender, IRibbonControl control, bool pressed, ADXCancelEventArgs e) {
    object context = control.Context;

    if (context is Outlook.Explorer explorer) {
        Outlook.Selection selection = null;
        try {
            selection = explorer.Selection;
        }
        catch { // ignore error
        }
        if (selection == null) {
            // trace message
            Marshal.ReleaseComObject(context); context = null;
            return;
        }
        if (selection.Count != 1) {
            // trace message
            Marshal.ReleaseComObject(context); context = null;
            return;
        }
        if (selection[1] is Outlook.MailItem mailItem) {
            // same code here that is called by
            // ProcessReplyAll in ItemEventsClass.cs
            Marshal.ReleaseComObject(mailItem); mailItem = null;
        }

    }
    Marshal.ReleaseComObject(context); context = null;
}


I must be doing something wrong here, since commenting out this code resolves my issue. What am I missing?

Robert
Posted 13 Jul, 2022 01:59:37 Top
Andrei Smolin


Add-in Express team


Posts: 18816
Joined: 2006-05-11
Hello Robert,

Send me the ProcessReplyAll() method from ItemEventsClass.cs to the support email address; find it in {Add-in Express installation folder}\readme.txt. Also, show me how you invoke that method.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jul, 2022 04:13:58 Top
Roberto Esguerra




Posts: 22
Joined: 2022-01-31
Andrei,

I sent the code you requested in an email to the support email address. The subject line of the email is "code requested by Andrei Smolin". The code is embedded in the email body.

Robert
Posted 13 Jul, 2022 19:46:37 Top
Andrei Smolin


Add-in Express team


Posts: 18816
Joined: 2006-05-11
Hello Robert,

Thank you. There are several COM objects which you need to release. Please check my email. Not sure if these relate to the issue but I?Â?Ð?éve seen so many strange things?Â?Ð??

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Jul, 2022 05:48:57 Top
Roberto Esguerra




Posts: 22
Joined: 2022-01-31
Andrei,

The code changes you suggested in my custom object did not resolve my issues. As the changes are good ones, I?Â?Ð?éve left them in place.

I sent a follow-up email to the support address, with some code to explain what else I attempted. I hope it helps.

Robert
Posted 14 Jul, 2022 19:54:05 Top
Andrei Smolin


Add-in Express team


Posts: 18816
Joined: 2006-05-11
Hello Robert,

Thank you. I've sent you a test project that we could use to investigate the issue.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 15 Jul, 2022 05:23:45 Top
Roberto Esguerra




Posts: 22
Joined: 2022-01-31
Andrei,

I answered your last email. I'm hoping together we can solve my problem this week. What additional information do you need from me?

Robert
Posted 19 Jul, 2022 02:25:54 Top