nvoigt, Worked great. Thanks! Just set up a loop to repeatedly invoke WaitForInputIdle on the Outlook process until we get true in response.
However I have found a new problem.... When I run my app in debug everything is fine and dandy, but if I run it without debugging Outlook loses focus to my application and my SendKeys created CRLF's are received by the wrong app.
So I did some research and the best thing I have found is a somewhat kludgey way to make sure that Outlook has focus when I sent the CRLFs. I got this technique from http://www.bobpowell.net/tipstricks.htm. Adapted to my code it looks like this:
Code:
using System.Runtime.InteropServices;
[DllImport("User32.dll")]
public static extern int ShowWindowAsync(IntPtr hWnd , int swCommand);
.
.
.
ShowWindowAsync(theOutlookProcessInstance.MainWindowHandle, 2)
ShowWindowAsync(theOutlookProcessInstance.MainWindowHandle, 9)
This should theoretically minimize and then restore the window defined by the hWnd arg of the function.
The problem is that get the following compile error:
Compiler Error CS1518: Expected class, delegate, enum, interface, or struct
The squiggly line in the code indicating where the error is, is unter the return value in the ShowWindowAsyc function declaration.
I have tried importing other dll's and declaring other functions and get the same error, so its not particular to this DLL or function. The syntax I see in other similar examples on the web is identical. Anyone have a guess? Maybe I should start a new thread on this problem....
Thanks again for your help!
Zak