none
Outlook shows automatically the last opened msg file RRS feed

  • Question

  • I am faced with the following problem:
    Outlook 2010 has just been opened. Before any other action in Outlook I open a msg file from Windows Explorer and close it again. Then I
    connect programatically in C# to Outlook (works also with VB.NET or any other programming environment):

    Microsoft.Office.Interop.Outlook.Application olApp;
    olApp = new Microsoft.Office.Interop.Outlook.Application();

    The connection works without error, but Outlook opens immediately the previously opened msg file. This only works once, right after you open Outlook.
    Is this a known behavior?
    How can you prevent this?

    Thanks for your help.


    • Edited by SWeilhammer Thursday, November 22, 2012 4:59 PM
    Thursday, November 22, 2012 4:52 PM

Answers

  • Hi SWeilhammer,

    Thanks for posting in the MSDN Forum.

    On my side I use following code to prevent this behavior:

                Outlook.Application olApp = null;
                Process[] ps = Process.GetProcessesByName("OUTLOOK");
                if (ps.Length > 0)
                {
                    olApp = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
                }
                else
                {
                    olApp = new Outlook.Application();
                }

    I hope it can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, November 23, 2012 8:40 AM
    Moderator