Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

EWS, MSG.exe and Windows Services

$
0
0

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.


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>