在 C# 中使用 BCC 不带 TO 通过 SMTP 发送邮件
我正在尝试使用 C# 中的 System.Net.Mail.MailMessage 类创建一封电子邮件,该电子邮件全部通过密件抄送发送到电子邮件地址列表。 我不想包含 TO
地址,但似乎我必须包含,因为如果我在 中对
TO
地址使用空字符串,则会出现异常MailMessage 构造函数。 该错误指出:
ArgumentException
The parameter 'addresses' cannot be an empty string.
Parameter name: addresses
当然可以仅使用 BCC
发送电子邮件,因为这不是 SMTP 的限制。
有办法解决这个问题吗?
I am trying to use the System.Net.Mail.MailMessage
class in C# to create an email that is sent to a list of email addresses all via BCC
. I do not want to include a TO
address, but it seems that I must because I get an exception if I use an empty string for the TO
address in the MailMessage
constructor. The error states:
ArgumentException
The parameter 'addresses' cannot be an empty string.
Parameter name: addresses
Surely it is possible to send an email using only BCC
as this is not a limitation of SMTP.
Is there a way around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我认为如果您注释掉整个
emailMessage.To.Add(sendTo);
行,它将发送To
字段为空的电子邮件。I think if you comment out the whole
emailMessage.To.Add(sendTo);
line , it will send the email withTo
field empty.对内部邮件群发执行同样的操作,您不希望人们一直回复所有人。
将其发送给您自己(或虚拟帐户),然后添加您的密件抄送列表。
Do the same thing you do for internal mail blasts where you don't want people to reply-to-all all the time.
Send it to yourself (or a dummy account), then add your BCC list.
它甚至不需要是真实的电子邮件地址,我通常使用
[email protected]
表示TO
,NoReply@CompanyName
表示FROM
。It doesn't even need to be a real e-mail address, I typically use
[email protected]
forTO
, andNoReply@CompanyName
forFROM
.您必须包含一个 TO 地址。 只需将其发送到您不介意接收邮件的“垃圾”电子邮件地址即可。
You have to include a TO address. Just send it to a "junk" email address that you don't mind getting mail on.
只是不要在 To 属性上调用 Add-方法。
Just don't call the Add-method on the To-property.
必须有一个地址。 自从 80 年代最初的 sendmail 实现以来一直都是这种方式,据我所知,所有 SMTP 邮件程序都有相同的要求。 您可以只使用一个虚拟地址。
Must have a to address. It has been this way since the original sendmail an implementations in the 80s and all SMTP mailers, I know of, have the same requirement. You can just use a dummy address for to.
您可以使用临时假地址,然后立即将其删除:
You can use a temporary fake address then remove it just after:
我认为您正在尝试做类似的事情:
这就是您看到错误消息的原因。
相反,尝试这样的事情:
I think you were trying to do something like :
That's why you were seeing the error message.
Instead, try something like this: