none
Automating the Move of a Recall Item to another folder with C# RRS feed

  • Question

  • I am working on a task to automate the organization of archived messages.  When Trying to move an Outlook 'Recall' message the following dialog is created in Outlook 2010:

    "The custom form cannot be opened.  Outlook will use an Outlook form instead.  The object does not support the requested action."

    My only option is to hit 'OK'.  Once I do, the message returns again and when I click OK the second time the message is moved to the folder as expected.

    The code is simply:  _MailItem.Move(_DestinationFolder);

    On this line, everythign is fine.  The dialogs are displayed within the Move method.

    This was not an issue with Outlook 2007.  We just upgraded to 2010 and this started happening and is a huge annoyance (it happens on other messages too; but consistently on recall messages).

    The issue is this task is suppose to be automated so no one has to watch it and click on 'dailog' windows. 
    I followed web resources to clear the custom form cache, create a new profile, and even reisntalled outlook.   Just for grins I even setup a brand new machine and tried it there as well.  

    Anyone have any ideas on how I can supress the dialog or hook it to automate the click of an 'OK'?  

    Tuesday, December 18, 2012 3:23 PM

Answers

  • Klaus,

    I apologize for my delays in getting back to you.,  I have been out for the holidays, vacation, and sick.  I thought I would just get everything done all at once.

    Anyway, I do have a working solution to closing the dialogs through automation. 

    It is a bit more complex than just the alert box because I have other situations occuring that I need to address so, I am just going to paraphase what I am doing in my code.  You will want to reference http://www.pinvoke.net/ and search the web for actual code use and information.

    First, I use System.Component.BackgroundWorker which will use the User32.GetWindowText (see the pinvoke website) to loop over all the windows for one with "microsoft office" in the title.
    To ensure that I have the dialog popup, I use User32.EnumChildWindows to look for the text on the elements within the popup.  I save a reference to the "OK" button's window handle and if I find the text from the alert, I choose to click the "OK" button by using the following:

    SendMessage(OKButtonID, 245, 0 , 0);

    This dialog will popup a second dialog.  So, I added a pause for 1.5 seconds to give the second popup time to appear and repeated my loop over the EnumChildWindows until the dialog no longer appears.

    • Marked as answer by Sun Down Friday, January 18, 2013 12:54 PM
    Friday, January 18, 2013 12:54 PM

All replies

  • BTW, I am using the Microsoft.Office.Interop.Outlook runtime Version: v2.0.50727 Version: 14.0.0.0
    Tuesday, December 18, 2012 3:25 PM
  • Hi "Sun Down"

    Thanks for posting in the MSDN Forum.

    What's mean of

    The custom form cannot be opened.  Outlook will use an Outlook form instead.  The object does not support the requested action

    Do you handle your issue use a desktop application (Windows form application or WPF application) instead of Outlook add-in?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 20, 2012 1:11 AM
    Moderator
  • Tom,

        Thanks for the reply, the Custom form message you are asking me about is a dialog that is coming from Outlook.  Programatically I am using desktop application and this happens when I attempt to move the "recall" messages out of our archive folders. 

        I can open the message.  I can read the message.  I can alter the message.  I can save the message.  I just cannot Move the message.  Whenever the message is moved, I get this prompt. 

    The message was originally created in Outlook 2007.  Currently, the organization I am helping is running on 2007.  They wish to upgrade to 2010.  But, issues like this are preventing them from moving forward.

    Thursday, December 20, 2012 1:18 PM
  • Hi Sun,

    Where the folder is? Is it in the same store (your said this is a archived message, so I suppose that you message is store in a pst file and the target folder is in that pst file too.)?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 21, 2012 6:19 AM
    Moderator
  • Tom,

    The complete process is as follows:
    1) Messages are archived within Exchange.  They are saved in a folder as an attachment to another message.  (The Exchange message we refer to as the envelope and the attachment is the orginal message)

    2) The envelopes are processed based upon user properties in the attachment.  (To access each attachment they are saved locally as a .msg file and then opened as a mail item.)

    3) Business rules are applied to each of the original message which may move the message to a public folder.  The public folder is owned by the same account where the envelope is stored.

    4) The envelope is archived into another folder so it will not be processed a second time.

    If I set a break point on the code to MOVE the message, everythign appears fine.  If I step into over the move statement I get the dialog pop-up as described earlier in this thread and I have to click okay on that dialog and the message will move, the envelop will move.  There are no other issues. But for some reason within the interop code for MOVE, I get the aforementioned dialog on recall messages.

    I would just like a way to supress that window or automatically select OK (that's the only option I have to select anyway).

    Friday, December 21, 2012 3:31 PM
  • Hi Sun,

    It seems that all of the process will be finished on Exchange side. Is it right? And Outlook just a kind of client for Exchange server. I would recommend consult at Exchange forum if your issue occurred on Exchange side.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 24, 2012 7:19 AM
    Moderator
  • Hi,

    it is pretty clear that the problem is on the Outlook side, the Exchange forum will not be helpful.

    Obviously, Outlook tries to open a form that it currently does not have.

    Anyway, the original question is:

    'Anyone have any ideas on how I can supress the dialog or hook it to automate the click of an 'OK'?' 

    I would like an answer to that question, too. Any help is appreciated.

    /Klaus

    Wednesday, January 16, 2013 8:15 AM
  • Klaus,

    I apologize for my delays in getting back to you.,  I have been out for the holidays, vacation, and sick.  I thought I would just get everything done all at once.

    Anyway, I do have a working solution to closing the dialogs through automation. 

    It is a bit more complex than just the alert box because I have other situations occuring that I need to address so, I am just going to paraphase what I am doing in my code.  You will want to reference http://www.pinvoke.net/ and search the web for actual code use and information.

    First, I use System.Component.BackgroundWorker which will use the User32.GetWindowText (see the pinvoke website) to loop over all the windows for one with "microsoft office" in the title.
    To ensure that I have the dialog popup, I use User32.EnumChildWindows to look for the text on the elements within the popup.  I save a reference to the "OK" button's window handle and if I find the text from the alert, I choose to click the "OK" button by using the following:

    SendMessage(OKButtonID, 245, 0 , 0);

    This dialog will popup a second dialog.  So, I added a pause for 1.5 seconds to give the second popup time to appear and repeated my loop over the EnumChildWindows until the dialog no longer appears.

    • Marked as answer by Sun Down Friday, January 18, 2013 12:54 PM
    Friday, January 18, 2013 12:54 PM
  • You aren't trying to use the Outlook object model from a background thread, are you? That's not supported at all and never has been. In fact, in Outlook 2013 if you try to use the object model from a background thread Outlook will terminate your code.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Sun Down" <=?utf-8?B?U3VuIERvd24=?=> wrote in message news:14c2264d-9f4e-4170-83ab-ff28baa3ef31...

    Klaus,

    I apologize for my delays in getting back to you.,  I have been out for the holidays, vacation, and sick.  I thought I would just get everything done all at once.

    Anyway, I do have a working solution to closing the dialogs through automation. 

    It is a bit more complex than just the alert box because I have other situations occuring that I need to address so, I am just going to paraphase what I am doing in my code.  You will want to reference http://www.pinvoke.net/ and search the web for actual code use and information.

    First, I use System.Component.BackgroundWorker which will use the User32.GetWindowText (see the pinvoke website) to loop over all the windows for one with "microsoft office" in the title.
    To ensure that I have the dialog popup, I use User32.EnumChildWindows to look for the text on the elements within the popup.  I save a reference to the "OK" button's window handle and if I find the text from the alert, I choose to click the "OK" button by using the following:

    SendMessage(OKButtonID, 245, 0 , 0);

    This dialog will popup a second dialog.  So, I added a pause for 1.5 seconds to give the second popup time to appear and repeated my loop over the EnumChildWindows until the dialog no longer appears.


    Ken Slovak MVP - Outlook
    Friday, January 18, 2013 3:09 PM
    Moderator
  • no, my background worker process is merely looking at the open windows via the User32.dll and looking at the text on them.  If it finds the one with the message "The custom form cannot be opened.  Outlook will use an Outlook form instead.  The object does not support the requested action." it clicks the OK button.
    Friday, January 18, 2013 4:23 PM
  • Cool! Thanks!
    Thursday, January 31, 2013 3:07 PM