none
EWS, MSG.exe and Windows Services RRS feed

  • Question

  • Task is to send notification to a user whenever an email arrives into a public folder. I created a windows service with EWS subscription service and whenever NewMail or Created event occurs, the OnEvent creates a MSG command to send a notification to the user that email is waiting for him in the public folder.

    For sending the notification I am using the Process class:

    string sCMD = @"MSG.exe " + user + " /Server " + pc + " /Time 0 " + msg

    System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                    startInfo.FileName = "cmd.exe";
                    startInfo.Arguments = "/c " + sCMD;
                    startInfo.UseShellExecute = false;
                    startInfo.CreateNoWindow = true;
                    startInfo.RedirectStandardError = true;

                    startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    System.Diagnostics.Process proc = new System.Diagnostics.Process();
                    proc.StartInfo = startInfo;
                  
                    proc.Start();
                    string error = proc.StandardError.ReadToEnd();
                    proc.WaitForExit();

    I am receiving the following error message:

    ‘MSG' is not recognized as an internal or external command, operable program or batch file.

    When I ran the same function from a forms application, it works. When I copied it to the Windows Services application, it is throwing the above error.  Any light on how to fix this  will be of great help.

    Appreciate your help.

    Sunday, January 12, 2014 3:44 PM

Answers

  • It worked when I gave the filename as MSG.exe

    startInfo.FileName = "msg.exe";

    • Marked as answer by ysku Monday, July 21, 2014 4:57 PM
    Monday, July 21, 2014 4:56 PM

All replies