I am using the code below to start a executable file from a windows service and I need to pass html code (stored in a variable) as an argument. I am escaping with double quotes but this is not working. What do I need to do in order to pass this correctly? Thanks in advance for any guidance that is offered.
Inside the service:
Process.Start(@"E:\Program Files\MyApp.exe", dr["rec"].ToString() +
" \"" + subject + "\" \"" + htmlVar);
and then within MyApp.exe:
static void Main(string[] args)
{
Program MyProg = new Program();
MyProg.MyMeth(args[0].ToString(), args[1].ToString(), args[2].ToString());
}
The exe file is just a simple app that handles the sending of emails. dr["rec"].ToString() is the email address of the recipient. The variable "subject" will contain the subject of the email. The variable "htmlVar" could contain anything, divs, images, hyperlinks, etc.. and the html code could be quite lengthy. Should I not be trying to pass this much data as an argument? Thanks again for the help.
You may need to encode the following characters to make them passable in a command line argument:
Be careful not to pass too much on the command-line:
I think 2000+ characters is starting to get too long.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With