I need to get focus on the already open New Mail form in outlook 2003 using C#, after pressing Yes button of a Message Box RRS feed

  • Question

  • Hi,

    While writing a new mail in Outlook 2003, as per my requirement on click of Send button it will validate some stuff. If validation got failed then it should display a Message box with YesNo Buttons.

    Now on click of Yes, I need to get the focus of the Mail form again(already opened) so that I can make the changes to the existing mail. But I am unable to get the information regarding same.

    Can anybody please help on the same?





    Saturday, March 19, 2011 3:35 PM


  • Hi Rajeev26,

    Thanks for posting in the MSDN Forum.

    I’m not able to get focus of the Mail form due to Inspector interface provide no property or method to do it. But I can provide some part of features like you description

    You can handle you issue like this snippet. It works fine on my side.

     using Outlook = Microsoft.Office.Interop.Outlook;
    Outlook.NameSpace ns = app.GetNamespace("MAPI");
    Outlook.MAPIFolder fld = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
    Outlook.MailItem item = fld.Items.Add(Outlook.OlItemType.olMailItem)as Outlook.MailItem;
    Outlook.Explorer explorer = app.Explorers.Add(fld,Outlook.OlFolderDisplayMode.olFolderDisplayNormal);
    Outlook.Inspector inspector = item.GetInspector;
    app.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(app_ItemSend);
    app_ItemSend(object Item, ref bool Cancel)
    DialogResult dr = MessageBox.Show("You information", "Item will be sent", MessageBoxButtons.YesNo);
    if (dr == DialogResult.No)
    Cancel = true;

    Have a good day,


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 22, 2011 10:24 AM