Come on, another weird way of assigning and checking Boolean!
Instead of
if (otlk.ProcessName.Contains("outlook"))
{
msOutlook = true;
}
if (msOutlook.Equals(true)) {
must be:
bool isOutlook;
isOutlook = otlk.ProcessName.Contains("outlook");
if (isOutlook)
This is just a side node: such quality of code as above demonstrates confusion about Boolean and simply unacceptable.
Now, the problem can be simply the case of the string.
Try instead:
isOutlook = otlk.ProcessName.ToLower().Contains("outlook");
After all, run Outlook, run this code under debugger, and identify the process representing Outlook "manually" looking the variable through debugger. Browse this instance of the
Process
and find out what differs it from other processes, build you check accordingly.
—SA