Open Outlook minimized

Our application checks to see if Outlook is running and if not opens it from our VB.NET application. We are trying to get it to open minimized and our code works fine with Outlook 2007 but 2010 ignores the parameters and opens up not minimized. I have searched and can't seem to find anyone that has tried this and reported problems. Does someone know how to do this?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello Friend!

First try this...

Then change the VB.NET App to run the shortcut instead of Outlook directly...


VerticalOneAuthor Commented:
Thanks for the suggestion and simpler is almost always better. I had considered that and maybe that is a compromise but I would much prefer a case that I can control it programmatically. Our users do not have our application running constantly not do they necessarily have Outlook running - this is a field service application being utilized by service technicians. I would much prefer to be able to inconspicuously open Outlook minimized when they open our app without having to set up a shortcut for their normal operation. Some users also may have Outlook 2007 and I am trying to figure out a programmatic way to make 2007 and 2010 work the same.

Maybe that is the best I can go but a programmatic solution would be much better.
Well, you indicated that doing it programatically wasn't really working...have you tried:

ProcessStartInfo openOutlook = new ProcessStartInfo("outlook.exe");
openOutlook.WindowStyle = ProcessWindowStyle.Minimized;

Something like that...

VerticalOneAuthor Commented:
Thanks for the suggestion and yes I had tried that. We eventually have gotten it to work but with a hack. We start the process as suggested and then go back to Process.GetProcessesByName to get a handle and force the minimize. This works but there needs to be a time delay before you can do the GetProcessesByName which varies on machines based on their speed. We put it in a loop and execute it 30 times with a 100 ms delay. This minimizes the window as fast as the machine will let us so the user sees a "ghost" of the window but it is then hidden. The overhead of this command does not seem to be too bad and although a hack it works. I really have no explanation why this is required on just Outlook 2010 and 2007 works just fine without it.

enum ShowWindowCommands : int {Hide = 0, Normal=1, ShowMinimized = 2, Maximized = 3, Minimize = 6}
       private static extern bool ShowWindow(IntPtr hwnd, ShowWindowCommands nCmdShow);

       Process p = new Process();
       p.StartInfo.FileName = "C:\\Program Files\\Microsoft Office\\Office14\\outlook.exe";
       p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
       p.StartInfo.CreateNoWindow = false;
       p.StartInfo.UseShellExecute = true;

//Put this section in a loop with 100 ms sleep between tries
//Actually we have another periodic process we used to fire this in our app

       Process[] ps = Process.GetProcessesByName("outlook");
              Process p2 = ps[0];
              ShowWindow(p2.MainWindowHandle, ShowWindowCommands.Hide);
       catch (Exception e)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.