I am trying to create a program that will create a new outlook message prepopulated with details using Outlook switches.
If I am in command prompt the following will successfully create a new blank message.
"C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE" /c ipm.note
I have found several posts here about how to use command prompt in c#, and have tried to get this same switch command to run from c# but it gives an error in the command prompt box that flashes: ipm.note is not recognized as an internal or external command, operable program or batch file.
I know ipm.note is correct for the switch, but apparently when passing it in the C# code it’s missing something? Possibly an escape character? Here’s my code that is in use.
System.Diagnostics.Process.Start("CMD.exe", "\"C:\\Program Files (x86)\\Microsoft Office\\Office14\\OUTLOOK.EXE\" /c ipm.note");
Also regarding this, I wanted to be able to use the @ symbol so I didn’t have to escape each special character, but I don’t know if you can use that and also add quotes inside a string, for example:
string temp = @""C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE" /c ipm.note"
In the above, the first set of quotes open and close then everything until the next set of quotes is not considered part of the string.
Recommendations on both of these situations are greatly appreciated.
You need to pass the /c switch to cmd.exe as well. Try this:
However, it would actually be far better to just run outlook.exe directly and avoid a lot of the argument problems:
In regard to your question about strings prefixed by the @ character, those strings are referred to as verbatim string literals. You can include a double quote inside one of these by using two double quotes together as I did in my code snippet.