I have an ASP.NET Web Form which was timing out when sending over 1800 emails whose addresses were being obtained from a DB. So I'm attempting to send the emails from a console application instead - I will access the DB there.
I need to pass the email subject line and body text as parameters to the ProcessStartInfo method but need guidance with the syntax. Can anyone help? Specifically, if I concatenate the subject and body vars and separate them with a space, will that suffice or will spaces in the vars cause problems?
Both the email subject and body should already contain spaces so you need to obey the same rules as if you were calling the program from the command line and enclose in "
the arguments that contain spaces, otherwise each space in the subject will delimit a new argument.
Another special case is if the subject and body already contain the "
character so you also need to account for that.
I think this should do the trick:
string subject = "Hello World!";
string body = @"This has "" quotes """;
string arguments = string.Format(
@"""{0}"" ""{1}""",
subject.Replace(@"""", @""""""),
body.Replace(@"""", @""""""));