I am currently creating a small application to display the contents of a user's inbox in Outlook. Double clicking the only window should open and activate Outlook.
All is working as expected when Outlook is actually open but if I close it or minimise it (despite the process still running in the background), I can't seen to get my application to make Outlook visible and make it the active window.
This code only works when Outlook is currently visible and behind other windows:
Declare Auto Function SetForegroundWindow Lib "USER32.DLL" _
(ByVal hWnd As IntPtr) As Boolean
Declare Function SetActiveWindow Lib "USER32.DLL" (ByVal hwnd As Long) As Long
Dim Outlook() As Process = Process.GetProcessesByName("Outlook")
If Outlook.Length > 0 Then
I would appreciate help getting my form to open/activate Outlook in any circumstance.