多的ProcessStartInfo参数 [英] ProcessStartInfo Multiple Arguments

查看:368
本文介绍了多的ProcessStartInfo参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经发送了电子邮件1800其地址,正在从数据库得到的时候这是超时的ASP.NET Web窗体。所以我试图从一个控制台应用程序,而不是发送的电子邮件 - 我将访问数据库有

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.

我需要通过电子邮件主题行和正文作为参数传递给的ProcessStartInfo 方法,但需要与语法指导。任何人都可以帮忙吗?特别是,如果我串联主题和正文VAR和他们用空格分隔,将那就够了,或将在瓦尔的空间会产生问题?

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.

我想这应该做的伎俩:

string subject = "Hello World!";

string body = @"This has "" quotes """;

string arguments = string.Format(
    @"""{0}"" ""{1}""", 
    subject.Replace(@"""", @""""""),
    body.Replace(@"""", @""""""));

这篇关于多的ProcessStartInfo参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆