T
Tom_Joseph2
Guest
Hello,
I open Outlook as another user using a Process.
With Win 10 and Outlook 2016, if a user's a/c/profile (whose trying to login as user to Outlook) is not in current system, Outlook exit's and shows 3 messages WITH TEXT as below :
1) Exclamation symbol
Outlook cannot log on. Verify you are connected to the network and are using the proper server and mailbox name. The MS Exchange info service in your profile is missing required info. Modify your profile to ensure that you are using the correct MS Exchange info Service. "Ok" button
2) Cross "X" Symbol
System resources are critically low. Close some windows. "Ok" button
3) Exclamation symbol
Cannot start MS Outlook. Cannot open Outlook window. The set of folders cannot be opened. The info store could not be opened. "Ok" button
Exit code is 0. No StandardError or StandardOutput is noted.
I ma trying to figure out how can I catch if such an error is happen thru Outlook. I have tried several different ways/things. Here's my code :
Public Event Exited As EventHandler
Public WithEvents OutlookProc As New Process
Private Sub LaunchOutlook(ByVal UserName As String, ByVal SecurePassword As SecureString, ByVal Domain As String)
Debug.WriteLine("************************************* LAUNCHING OUTLOOK begins ")
Try
Dim err As String = ""
Log.Add("LaunchOutlook: UserName " & UserName & " SecurePass Length: " & SecurePassword.Length & " Domain: " & Domain)
Dim OutlookProcess() As Process = System.Diagnostics.Process.GetProcessesByName("outlook")
'' TD - 2/14/2019
'' Added if clause to show msg dialog and return
If OutlookProcess.Count > 0 Then
MessageBox.Show("To open " & UserName.ToLower() & "'s profile, Please close Outlook and try again.", "Close Current Outlook", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Return
End If
'' TD - 2/14/2019
'' Above if, returns if true, so no need for this if
'If OutlookProcess.Count = 0 Then
Dim PSI As New ProcessStartInfo
PSI.UserName = UserName
PSI.Password = SecurePassword
PSI.Domain = Domain
Dim path As String = GetOutlookPath()
PSI.WorkingDirectory = IO.Path.GetPathRoot(path)
PSI.FileName = path & My.Settings.OutlookAppExe
PSI.Arguments = My.Settings.OutlookAppArgs
PSI.LoadUserProfile = True
PSI.UseShellExecute = False
PSI.RedirectStandardOutput = True
PSI.RedirectStandardError = True
If (IsNothing(OutlookProc)) Then
OutlookProc = New Process()
End If
OutlookProc.StartInfo = PSI
OutlookProc.EnableRaisingEvents = True
AddHandler OutlookProc.ErrorDataReceived, AddressOf Outlook_Error
AddHandler OutlookProc.OutputDataReceived, AddressOf Outlook_Output
OutlookProc.Start()
'Do While (OutlookProc.Responding)
err = OutlookProc.StandardError.ReadToEnd
OutlookProc.WaitForExit()
' Display errors caught/read
If (err <> "") Then
Debug.WriteLine("Errors Read : " + err)
End If
if (OutlookProc.StandardOutput.EndOfStream = False) Then
Debug.WriteLine("Std Output = " + OutlookProc.StandardOutput.ReadToEnd())
End If
'If (OutlookProc.HasExited) Then
'Exit While
'End If
'Loop
'Debug.WriteLine("OutlookProc STOPPED RESPONDING ")
Debug.WriteLine("Std Output = " + OutlookProc.StandardOutput.ReadToEnd())
Debug.WriteLine("OutlookProc STOP ")
Catch ex As Exception
Log.Add("LaunchOutlook Failed: " & ex.Message)
Debug.WriteLine("LaunchOutlook Failed: " & ex.Message)
MessageBox.Show(ex.Message, "Process Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Throw New Exception("Unable to launch Outlook: " & ex.Message)
Finally
' Debug.Print("OutlookProc Handle Name = " + OutlookProc.Handle.GetType().FullName)
OutlookProc.Close()
'OutlookProc = Nothing
End Try
Debug.WriteLine("************************************* END OF LAUNCHING OUTLOOK ")
End Sub
Private Sub Outlook_Exited(ByVal sender As Object, ByVal e As EventArgs) Handles OutlookProc.Exited
eventHandled = True
Debug.Print("************ Exit time: {0} \t Exit code: {1} \t Start time: {2} \t Duraction Time: {3}",
OutlookProc.ExitTime, OutlookProc.ExitCode, OutlookProc.StartTime, OutlookProc.ExitTime - OutlookProc.StartTime)
Debug.Print("************ Total Processor Time : {0} \t User Processor Time: {1} Privileged processor time {2} ",
OutlookProc.TotalProcessorTime.ToString(), OutlookProc.UserProcessorTime.ToString(), OutlookProc.PrivilegedProcessorTime.ToString())
End Sub
Private Sub Outlook_Error(ByVal sender As Object, ByVal e As EventArgs) Handles OutlookProc.ErrorDataReceived
Debug.Print("Outlook_ErrorDataReceived Event Handled")
' NEVER CAUGHT OR REACHED
End Sub
Private Sub Outlook_Output(ByVal sender As Object, ByVal e As EventArgs) Handles OutlookProc.OutputDataReceived
Debug.Print("Outlook_OutputDataReceived Event Handled")
' NEVER CAUGHT OR REACHED
End Sub
Private Sub Outlook_Disposed(ByVal sender As Object, ByVal e As EventArgs) Handles OutlookProc.Disposed
Debug.Print("Outlook_Disposed Event Handled")
End Sub
Results of 2 users : User1 (profile exsits on my PC) & User2 (profile Dows NOt exsists on my PC)
USER1 ''''' Quick. Open an email, a attachment & close
************************************* LAUNCHING OUTLOOK begins
Std Output = 02/18/19 11:15:16 Entered thread 0x2cd8: class Barracuda::BmaClient::CCacheCleanupThread
************ Exit time: 02/18/2019 11:15:30 \t Exit code: 0 \t Start time: 02/18/2019 11:15:15 \t Duraction Time: 00:00:14.5695867
************ Total Processor Time : 00:00:02.3593750 \t User Processor Time: 00:00:00.8437500 Privileged processor time 00:00:01.5156250
OutlookProc STOP
************************************* END OF LAUNCHING OUTLOOK
USER2
************************************* LAUNCHING OUTLOOK begins
************ Exit time: 02/18/2019 11:17:44 \t Exit code: 0 \t Start time: 02/18/2019 11:17:39 \t Duraction Time: 00:00:05.8152080
************ Total Processor Time : 00:00:01.1718750 \t User Processor Time: 00:00:00.2031250 Privileged processor time 00:00:00.9687500
OutlookProc STOP
************************************* END OF LAUNCHING OUTLOOK
'''''''''' Took some time to close the dlg msgs shown by Outlook
************************************* LAUNCHING OUTLOOK begins
************ Exit time: 02/18/2019 11:24:22 \t Exit code: 0 \t Start time: 02/18/2019 11:23:54 \t Duraction Time: 00:00:28.0353433
************ Total Processor Time : 00:00:01.1093750 \t User Processor Time: 00:00:00.2500000 Privileged processor time 00:00:00.8593750
Std Output =
OutlookProc STOP
************************************* END OF LAUNCHING OUTLOOK
With this, I think I can't rely on the Duration time of Outlook process.
What would be the best way to trap those messages from Outlook. Intention: Once I can get hold of that, I plan to execute another cmd that will open Outlook from command prompt. Opening outlook from cmd prompt let's user enter pswd and creates the profile for the newly logged in user. Though, I am not sure if I will be able to achieve this operation also.
Is their any way to track the messages shown by Outlook for not being able to open. Or any other way to figure out the same. Any help is highly appreciated.
Thank You
Continue reading...
I open Outlook as another user using a Process.
With Win 10 and Outlook 2016, if a user's a/c/profile (whose trying to login as user to Outlook) is not in current system, Outlook exit's and shows 3 messages WITH TEXT as below :
1) Exclamation symbol
Outlook cannot log on. Verify you are connected to the network and are using the proper server and mailbox name. The MS Exchange info service in your profile is missing required info. Modify your profile to ensure that you are using the correct MS Exchange info Service. "Ok" button
2) Cross "X" Symbol
System resources are critically low. Close some windows. "Ok" button
3) Exclamation symbol
Cannot start MS Outlook. Cannot open Outlook window. The set of folders cannot be opened. The info store could not be opened. "Ok" button
Exit code is 0. No StandardError or StandardOutput is noted.
I ma trying to figure out how can I catch if such an error is happen thru Outlook. I have tried several different ways/things. Here's my code :
Public Event Exited As EventHandler
Public WithEvents OutlookProc As New Process
Private Sub LaunchOutlook(ByVal UserName As String, ByVal SecurePassword As SecureString, ByVal Domain As String)
Debug.WriteLine("************************************* LAUNCHING OUTLOOK begins ")
Try
Dim err As String = ""
Log.Add("LaunchOutlook: UserName " & UserName & " SecurePass Length: " & SecurePassword.Length & " Domain: " & Domain)
Dim OutlookProcess() As Process = System.Diagnostics.Process.GetProcessesByName("outlook")
'' TD - 2/14/2019
'' Added if clause to show msg dialog and return
If OutlookProcess.Count > 0 Then
MessageBox.Show("To open " & UserName.ToLower() & "'s profile, Please close Outlook and try again.", "Close Current Outlook", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Return
End If
'' TD - 2/14/2019
'' Above if, returns if true, so no need for this if
'If OutlookProcess.Count = 0 Then
Dim PSI As New ProcessStartInfo
PSI.UserName = UserName
PSI.Password = SecurePassword
PSI.Domain = Domain
Dim path As String = GetOutlookPath()
PSI.WorkingDirectory = IO.Path.GetPathRoot(path)
PSI.FileName = path & My.Settings.OutlookAppExe
PSI.Arguments = My.Settings.OutlookAppArgs
PSI.LoadUserProfile = True
PSI.UseShellExecute = False
PSI.RedirectStandardOutput = True
PSI.RedirectStandardError = True
If (IsNothing(OutlookProc)) Then
OutlookProc = New Process()
End If
OutlookProc.StartInfo = PSI
OutlookProc.EnableRaisingEvents = True
AddHandler OutlookProc.ErrorDataReceived, AddressOf Outlook_Error
AddHandler OutlookProc.OutputDataReceived, AddressOf Outlook_Output
OutlookProc.Start()
'Do While (OutlookProc.Responding)
err = OutlookProc.StandardError.ReadToEnd
OutlookProc.WaitForExit()
' Display errors caught/read
If (err <> "") Then
Debug.WriteLine("Errors Read : " + err)
End If
if (OutlookProc.StandardOutput.EndOfStream = False) Then
Debug.WriteLine("Std Output = " + OutlookProc.StandardOutput.ReadToEnd())
End If
'If (OutlookProc.HasExited) Then
'Exit While
'End If
'Loop
'Debug.WriteLine("OutlookProc STOPPED RESPONDING ")
Debug.WriteLine("Std Output = " + OutlookProc.StandardOutput.ReadToEnd())
Debug.WriteLine("OutlookProc STOP ")
Catch ex As Exception
Log.Add("LaunchOutlook Failed: " & ex.Message)
Debug.WriteLine("LaunchOutlook Failed: " & ex.Message)
MessageBox.Show(ex.Message, "Process Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Throw New Exception("Unable to launch Outlook: " & ex.Message)
Finally
' Debug.Print("OutlookProc Handle Name = " + OutlookProc.Handle.GetType().FullName)
OutlookProc.Close()
'OutlookProc = Nothing
End Try
Debug.WriteLine("************************************* END OF LAUNCHING OUTLOOK ")
End Sub
Private Sub Outlook_Exited(ByVal sender As Object, ByVal e As EventArgs) Handles OutlookProc.Exited
eventHandled = True
Debug.Print("************ Exit time: {0} \t Exit code: {1} \t Start time: {2} \t Duraction Time: {3}",
OutlookProc.ExitTime, OutlookProc.ExitCode, OutlookProc.StartTime, OutlookProc.ExitTime - OutlookProc.StartTime)
Debug.Print("************ Total Processor Time : {0} \t User Processor Time: {1} Privileged processor time {2} ",
OutlookProc.TotalProcessorTime.ToString(), OutlookProc.UserProcessorTime.ToString(), OutlookProc.PrivilegedProcessorTime.ToString())
End Sub
Private Sub Outlook_Error(ByVal sender As Object, ByVal e As EventArgs) Handles OutlookProc.ErrorDataReceived
Debug.Print("Outlook_ErrorDataReceived Event Handled")
' NEVER CAUGHT OR REACHED
End Sub
Private Sub Outlook_Output(ByVal sender As Object, ByVal e As EventArgs) Handles OutlookProc.OutputDataReceived
Debug.Print("Outlook_OutputDataReceived Event Handled")
' NEVER CAUGHT OR REACHED
End Sub
Private Sub Outlook_Disposed(ByVal sender As Object, ByVal e As EventArgs) Handles OutlookProc.Disposed
Debug.Print("Outlook_Disposed Event Handled")
End Sub
Results of 2 users : User1 (profile exsits on my PC) & User2 (profile Dows NOt exsists on my PC)
USER1 ''''' Quick. Open an email, a attachment & close
************************************* LAUNCHING OUTLOOK begins
Std Output = 02/18/19 11:15:16 Entered thread 0x2cd8: class Barracuda::BmaClient::CCacheCleanupThread
************ Exit time: 02/18/2019 11:15:30 \t Exit code: 0 \t Start time: 02/18/2019 11:15:15 \t Duraction Time: 00:00:14.5695867
************ Total Processor Time : 00:00:02.3593750 \t User Processor Time: 00:00:00.8437500 Privileged processor time 00:00:01.5156250
OutlookProc STOP
************************************* END OF LAUNCHING OUTLOOK
USER2
************************************* LAUNCHING OUTLOOK begins
************ Exit time: 02/18/2019 11:17:44 \t Exit code: 0 \t Start time: 02/18/2019 11:17:39 \t Duraction Time: 00:00:05.8152080
************ Total Processor Time : 00:00:01.1718750 \t User Processor Time: 00:00:00.2031250 Privileged processor time 00:00:00.9687500
OutlookProc STOP
************************************* END OF LAUNCHING OUTLOOK
'''''''''' Took some time to close the dlg msgs shown by Outlook
************************************* LAUNCHING OUTLOOK begins
************ Exit time: 02/18/2019 11:24:22 \t Exit code: 0 \t Start time: 02/18/2019 11:23:54 \t Duraction Time: 00:00:28.0353433
************ Total Processor Time : 00:00:01.1093750 \t User Processor Time: 00:00:00.2500000 Privileged processor time 00:00:00.8593750
Std Output =
OutlookProc STOP
************************************* END OF LAUNCHING OUTLOOK
With this, I think I can't rely on the Duration time of Outlook process.
What would be the best way to trap those messages from Outlook. Intention: Once I can get hold of that, I plan to execute another cmd that will open Outlook from command prompt. Opening outlook from cmd prompt let's user enter pswd and creates the profile for the newly logged in user. Though, I am not sure if I will be able to achieve this operation also.
Is their any way to track the messages shown by Outlook for not being able to open. Or any other way to figure out the same. Any help is highly appreciated.
Thank You
Continue reading...