none
fire reply event RRS feed

  • Question

  • Hi all

    Need a code example of how to fire the "reply" event.  I need to do this within the newinspector_activate event.  The "reply" button has already been pressed - the one on the ribbon not in the message form.  I am trying to force the "high level" (the one on the ribbon) reply selection through the same code as the reply selection from the opened message form.  The examples I have seen on the web are VB.net variants - they do no work.  What I am ultimately trying to do is to get to the cancel function.  I want to display the send form using an RDOmail object and then cancel the Outlook "default send form" which my code in the "low level" reply event does.  Any help would be greatly appreciated - been losing on this one for a long time!

    Respectfully,

    Gordon Haas


    Gordon Haas

    Monday, March 4, 2013 4:01 PM

Answers

  • I don't think what you see are holes in the object model, the OOM just wasn't designed to do what you want to do.
     
    When NewInspector() fires it does so when a new Inspector is first created. At that time the Inspector object is what's called a "weak object reference". That means that only some of its properties are fully populated. During the first Inspector.Activate() event is the first time you get a "strong" reference where all the properties are fleshed out.
     
    In no cases can you execute a method forcing an event such as Inspector.Close() to fire during the handling of another Inspector event. That's where the timer comes in, to allow you to call the Inspector.Close() method after execution of the event finishes.
     
    I don't know about any"phantom" Inspectors, but you can check and prove or disprove that by hitting a breakpoint in the relevant event handlers and using Spy++ to see what windows the Outlook.Application process has open at those times.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "saahg" <=?utf-8?B?c2FhaGc=?=> wrote in message news:e3fda087-5e7b-40b9-8fe0-454cd9ae4a2c...

    Thanks Ken for the continuous update.

    So where do you close the inspector?  It is beginning to appear as though the inspector.close method is a non event - pardon the pun.  What I am discovering is the new inspector event does not fire unless you manually select another item in the inbox list.  I proved this by setting the inspector activate "object" to nothing BEFORE the "message:send" form was displayed automatically by Outlook.  This form display did not fire the new inspector event.  I guess the form is displayed by way of a "phantom inspector" which can't be accessed in any manor, way, shape or form!  To digress I was able to close the "inspector" passed object in the new inspector event which is basically useless when you are trying to close the form that was displayed by the "phantom inspector".  There are a lot holes in this OOM!  Hopefully, the timer suggestion is going to be the solution - that is my next saga.

    Respectfully,

    Gordon Haas


    Gordon Haas


    Ken Slovak MVP - Outlook
    • Marked as answer by saahg Wednesday, March 6, 2013 9:01 PM
    Wednesday, March 6, 2013 8:06 PM
    Moderator

All replies

  • I don't fully understand what you're trying to do or why. Are you trying to prevent a reply from being shown, and to substitute your own form instead?
     
    I would handle that by repurposing the ribbon controls for reply and reply all in the Explorer and the Explorer context menus, and when an item is opened I'd also repurpose the controls on the Inspector ribbons. If you do that you can just not let the original button actions run and only run your own actions.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "saahg" <=?utf-8?B?c2FhaGc=?=> wrote in message news:304aadea-0cac-4555-bf64-3ee1c4821945...

    Hi all

    Need a code example of how to fire the "reply" event.  I need to do this within the newinspector_activate event.  The "reply" button has already been pressed - the one on the ribbon not in the message form.  I am trying to force the "high level" (the one on the ribbon) reply selection through the same code as the reply selection from the opened message form.  The examples I have seen on the web are VB.net variants - they do no work.  What I am ultimately trying to do is to get to the cancel function.  I want to display the send form using an RDOmail object and then cancel the Outlook "default send form" which my code in the "low level" reply event does.  Any help would be greatly appreciated - been losing on this one for a long time!

    Respectfully,

    Gordon Haas


    Gordon Haas


    Ken Slovak MVP - Outlook
    Monday, March 4, 2013 6:39 PM
    Moderator
  • Thank you Ken for the quick response.

    No what I am trying to do is cancel the display of the "default send message form".  The ribbon level Reply button/function fires the new inspector_activate event but not the reply event.  In my reply event code which is fired when the message is OPENED and the reply on the message form is clicked I display the RDOmail item data in the "send message form" and then cancel the Outlook "default send message form" (with the wrong data) after the RDOmail "send form" is "sent".  I want the same sequence of events to happen when the ribbon Reply button is pressed.  That is the RDOmail item is created, the appropriate fields modified, then copied, and saved in the new inspector_activate event with the exception there is no opened message form displayed with a Reply option (that fires the reply event!).  I have done all of the prerequisite steps in the new inspector_activate event I just don't know how to get to the reply event code so I can complete the function and most important of all gain access to the CANCEL function after I display the "send" form with the RDOmail data.  If you can tell me how I can get to an equivalent cancel function then I will go that route - have not found any data on that either.  BTW I am using the RDOmail object because I need to change "certain" fields prior to displaying the form.

    Respectfully,

    Gordon Haas

     


    Gordon Haas

    Monday, March 4, 2013 7:29 PM
  • Where is this code running? Is it in the Outlook VBA project or a COM addin?

    If it's in a COM addin you can use Ribbon XML to repurpose any click of the Reply and ReplyAll ribbon controls using <command> nodes for both commands. If you do that you can prevent any Inspector from being opened and do whatever you want when the buttons are clicked. You can prevent the normal reply action from occurring at all.

    This link shows how to repurpose ribbon commands in Office 2007: http://msdn.microsoft.com/en-us/library/office/bb462633(v=office.12).aspx, the same principles apply for 2010 and 2013.


    Ken Slovak MVP - Outlook

    Monday, March 4, 2013 10:05 PM
    Moderator
  • Again thanks Ken.

    This is strictly a VBA project.  The route of repurposing the Ribbon Reply button seems to be a drastic one.  I simply want to supress the additional "default send" form by way of a cancel.  Is there no way to access or simulate a "cancel" method from the new Inspector_activate event or "bridge" to the reply event which has the cancel function by way of its argument list?  Lastly, if I go the repurpose solution can I somehow force the Ribbon Reply button to fire the "reply event"?

    Respectfully,

    Gordon Haas


    Gordon Haas

    Monday, March 4, 2013 10:44 PM
  • If this is VBA then you cannot handle anything ribbon related. Ribbon callbacks require a COM addin. You can't really do much of anything ribbon related from the Outlook VBA project.
     
    I don't believe you will be able to do what you want using VBA code. With a COM addin handling repurposing the controls you could, but not in VBA.
     
    When you repurpose a control you can execute your code and then cede control to the normal handler for that control, or you can cancel normal handling of the control after you do your processing.
     
    I think in VBA about all you could do is to handle the Reply() event on items that are selected in the ActiveExplorer. If you get ActiveExplorer.Selection and subscribe to SelectionChange() you can set up Reply() event handlers for all selected items. When the selection changes remove the existing handlers and add new handlers for whatever is now selected. You wouldn't be able to handle right-clicks though, only clicking Reply() and ReplyAll().
     
    When the handler fires you can then do your processing, cancel the reply so no new item is opened and do whatever you want from there.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "saahg" <=?utf-8?B?c2FhaGc=?=> wrote in message news:685b0b2c-c7b0-4270-8d6f-123cb5247082...

    Again thanks Ken.

    This is strictly a VBA project.  The route of repurposing the Ribbon Reply button seems to be a drastic one.  I simply want to supress the additional "default send" form by way of a cancel.  Is there no way to access or simulate a "cancel" method from the new Inspector_activate event or "bridge" to the reply event which has the cancel function by way of its argument list?  Lastly, if I go the repurpose solution can I somehow force the Ribbon Reply button to fire the "reply event"?

    Respectfully,

    Gordon Haas


    Gordon Haas


    Ken Slovak MVP - Outlook
    Tuesday, March 5, 2013 3:33 PM
    Moderator
  • I got what you are saying Ken.

    I have reduced this problem to one last step and that is the closing of a form using VBA which is suppose to work even by Dmitry's claim if I use the OOM mailitem which exposes this method.  I have the entryid of the mailitem but when I execute mailitem.close (olSave) the form does not close.  Now for some details:  the form is automatically displayed by Outlook (it is the message "send" form) when the execution leaves the inspector_activate event (I worked my way around needing the "cancel" function).  I am trying to close the form on the subsequent entry into the inspector_activate event.  I saved the entryid from the mailitem at exit time from the previous inspector_activate event.  The form has been minimized during this exit:entry sequence.  I have a method of detecting at the top of the inspector_activate event when I have a "pending opened form".  I reopen the Outlook mailitem using the following code:

           

           Dim mlrmv As Outlook.mailItem
           Dim outlookNS As Outlook.NameSpace
           Set outlookNS = Application.GetNamespace("MAPI")
           Set mlrmv = outlookNS.GetItemFromID(strSvEntid) strSvEntid is set at exit time from

    the inspector_activate event

           mlrmv.Close (olSave)

    The form does not close?  I have tried resetting the windowstate to normal but still no cigar.  I have also tried the same execution sequence at the new inspector event without success.  Does this have something to do with form access?  I thought the entryid access guaranteed me access to the current displayed form (even though it is minimized).  If I can get this close working I have completed the mission.  Any insight would be greatly appreciated!.

    Respectfully,

    Gordon Haas


    Gordon Haas

    Tuesday, March 5, 2013 9:19 PM
  • You can't close the Inspector during the Inspector.Activate() event handler. Just as you can't close it during Send() if you cancel the send. You have to be out of the event handler.
     
    What I do in COM addin code is use a timer in Activate() (or Send()). When the timer fires the handler can close the Inspector. In managed code you'd need to ensure the timer is running in the Outlook thread, as you cannot call into the Outlook object model from a background thread.
     
    In VBA code it would be much trickier, as you'd have to set up and use a Win32 API timer. I haven't done that in years, but I'm pretty sure that would be marshaled back to the Outlook thread in the VBA project. If not your code could crash Outlook or be disabled by Outlook.
     
    Here's a link to code for an API timer in VBA code: http://vbusers.com/code/codeget.asp?ThreadID=61&PostID=1
     
     

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "saahg" <=?utf-8?B?c2FhaGc=?=> wrote in message news:37cfd20b-8fc9-4a40-9fd6-c94e15733a35...

    I got what you are saying Ken.

    I have reduced this problem to one last step and that is the closing of a form using VBA which is suppose to work even by Dmitry's claim if I use the OOM mailitem which exposes this method.  I have the entryid of the mailitem but when I execute mailitem.close (olSave) the form does not close.  Now for some details:  the form is automatically displayed by Outlook (it is the message "send" form) when the execution leaves the inspector_activate event (I worked my way around needing the "cancel" function).  I am trying to close the form on the subsequent entry into the inspector_activate event.  I saved the entryid from the mailitem at exit time from the previous inspector_activate event.  The form has been minimized during this exit:entry sequence.  I have a method of detecting at the top of the inspector_activate event when I have a "pending opened form".  I reopen the Outlook mailitem using the following code:

           

           Dim mlrmv As Outlook.mailItem
           Dim outlookNS As Outlook.NameSpace
           Set outlookNS = Application.GetNamespace("MAPI")
           Set mlrmv = outlookNS.GetItemFromID(strSvEntid) strSvEntid is set at exit time from

    the inspector_activate event

           mlrmv.Close (olSave)

    The form does not close?  I have tried resetting the windowstate to normal but still no cigar.  I have also tried the same execution sequence at the new inspector event without success.  Does this have something to do with form access?  I thought the entryid access guaranteed me access to the current displayed form (even though it is minimized).  If I can get this close working I have completed the mission.  Any insight would be greatly appreciated!.

    Respectfully,

    Gordon Haas


    Gordon Haas


    Ken Slovak MVP - Outlook
    Wednesday, March 6, 2013 3:43 PM
    Moderator
  • Thanks Ken for the continuous update.

    So where do you close the inspector?  It is beginning to appear as though the inspector.close method is a non event - pardon the pun.  What I am discovering is the new inspector event does not fire unless you manually select another item in the inbox list.  I proved this by setting the inspector activate "object" to nothing BEFORE the "message:send" form was displayed automatically by Outlook.  This form display did not fire the new inspector event.  I guess the form is displayed by way of a "phantom inspector" which can't be accessed in any manor, way, shape or form!  To digress I was able to close the "inspector" passed object in the new inspector event which is basically useless when you are trying to close the form that was displayed by the "phantom inspector".  There are a lot holes in this OOM!  Hopefully, the timer suggestion is going to be the solution - that is my next saga.

    Respectfully,

    Gordon Haas


    Gordon Haas

    Wednesday, March 6, 2013 6:07 PM
  • I don't think what you see are holes in the object model, the OOM just wasn't designed to do what you want to do.
     
    When NewInspector() fires it does so when a new Inspector is first created. At that time the Inspector object is what's called a "weak object reference". That means that only some of its properties are fully populated. During the first Inspector.Activate() event is the first time you get a "strong" reference where all the properties are fleshed out.
     
    In no cases can you execute a method forcing an event such as Inspector.Close() to fire during the handling of another Inspector event. That's where the timer comes in, to allow you to call the Inspector.Close() method after execution of the event finishes.
     
    I don't know about any"phantom" Inspectors, but you can check and prove or disprove that by hitting a breakpoint in the relevant event handlers and using Spy++ to see what windows the Outlook.Application process has open at those times.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "saahg" <=?utf-8?B?c2FhaGc=?=> wrote in message news:e3fda087-5e7b-40b9-8fe0-454cd9ae4a2c...

    Thanks Ken for the continuous update.

    So where do you close the inspector?  It is beginning to appear as though the inspector.close method is a non event - pardon the pun.  What I am discovering is the new inspector event does not fire unless you manually select another item in the inbox list.  I proved this by setting the inspector activate "object" to nothing BEFORE the "message:send" form was displayed automatically by Outlook.  This form display did not fire the new inspector event.  I guess the form is displayed by way of a "phantom inspector" which can't be accessed in any manor, way, shape or form!  To digress I was able to close the "inspector" passed object in the new inspector event which is basically useless when you are trying to close the form that was displayed by the "phantom inspector".  There are a lot holes in this OOM!  Hopefully, the timer suggestion is going to be the solution - that is my next saga.

    Respectfully,

    Gordon Haas


    Gordon Haas


    Ken Slovak MVP - Outlook
    • Marked as answer by saahg Wednesday, March 6, 2013 9:01 PM
    Wednesday, March 6, 2013 8:06 PM
    Moderator
  • Thanks Ken for all of the insights.  You did confirm what I suspected that the inspector.close method has to be called from outside of the inspector events for one reason or the other, but the question remains from what "construct" will the timer be calling the inspector.close method - hopefully the SPY++ utility will tell me that.

    Respectfully,

    Gordon Haas


    Gordon Haas

    Wednesday, March 6, 2013 9:07 PM