简体   繁体   English

System.Net.Mail.MailAddress不允许Gmail GROUP联系人

[英]System.Net.Mail.MailAddress does not allow Gmail GROUP contact

I am using a Gmail business account, say noreply@mycompany.com to send a daily email reports to a few of my clients whose email addresses are from different domains. 我正在使用Gmail商家帐户,例如noreply@mycompany.com ,将每日电子邮件报告发送给我的一些客户,这些客户的电子邮件地址来自不同的域。 I use C# to send my email to Gmail's SMTP server. 我使用C#将我的电子邮件发送到Gmail的SMTP服务器。

var receiver = new MailAddress("receiver@domain1.com");
var receiver = new MailAddress("receiver@domain2.com");
var receiver = new MailAddress("receiver@domain3.com");

After a while I found out I had to modify code every time a new customer demands email report. 过了一会儿,我发现每次新客户要求电子邮件报告时我都必须修改代码。 So I want to make a group and maintain that group. 所以我想成立一​​个小组并维持这个小组。 Gmail has a Add Group settings in your account's "Contacts" page so I used that to create a group named ReportGroup and added those people. Gmail在您的帐户的“通讯录”页面中有一个添加组设置,因此我使用该设置创建了一个名为ReportGroup的组并添加了这些人。 And in the code, this lines throws exception: 在代码中,这行抛出异常:

var receiver = new MailAddress("ReportGroup");

saying The specified string is not in the form required for an e-mail address. say The specified string is not in the form required for an e-mail address.

Well apparently this isn't a legit email address. 显然这不是一个合法的电子邮件地址。 Is there a way I can bypass this format check? 有没有办法绕过这种格式检查? Or is it doesn't make sense to do so? 或者这样做没有意义?

In further attempts, I tried to name my group as reportgroup@mycompany.com . 在进一步尝试中,我尝试将我的组命名为reportgroup@mycompany.com This time the email got sent without complain however the gmail server rejects the receiver, claiming that 这次电子邮件没有抱怨就发送了,但是gmail服务器拒绝了接收者,声称这样

50-5.1.1 The email account that you tried to reach does not exist. Please try
550-5.1.1 double-checking the recipient's email address for typos or
550-5.1.1 unnecessary spaces. Learn more at
550 5.1.1  https://support.google.com/mail/answer/6596 ai2si23882633pad.98 - gsmtp

So this isn't the way to go either. 所以这不是要走的路。 Could any one suggest a solution for me to allow someone non-programmer to maintain an receiver list to which my code sends report to? 任何人都可以建议我允许某个非程序员维护我的代码发送到的接收者列表的解决方案吗?

Create an alias for your group, and then send email to that address. 为您的组创建别名 ,然后将电子邮件发送到该地址。 Then you can continue to maintain the group as you normally do. 然后,您可以像往常一样继续维护该组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RegEx由System.Net.Mail.MailAddress使用 - Is RegEx used by System.Net.Mail.MailAddress System.Net.Mail.MailAddress使用一个参数发送到多封电子邮件 - System.Net.Mail.MailAddress send to multiple emails with one parameter 无法将System.Net.Mail.MailAddress序列化为Json - Unable to serialize System.Net.Mail.MailAddress to Json 无法将类型“System.Net.Mail.MailAddress”隐式转换为“SendGrid.Helpers.Mail.EmailAddress” - Cannot implicitly convert type 'System.Net.Mail.MailAddress' to 'SendGrid.Helpers.Mail.EmailAddress' 使用System.Net.Mail.MailAddress或其他库指定.eml文件名 - Specify .eml file name using System.Net.Mail.MailAddress or other library System.Net.Mail.MailAddress验证电子邮件缺少TLD,认为我@有效 - System.Net.Mail.MailAddress validates email missing TLD, considers me@there valid 为什么 System.Net.Mail.MailAddress 构造函数在域部分解析带有斜杠“/”的电子邮件? - Why System.Net.Mail.MailAddress constructor parses email with slash "/" in domain part? MailAddress构造函数如何验证邮件地址 - How does the MailAddress constructor validate mail addresses 为什么MailAddress不拒绝电子邮件地址someName @ gmail? - Why does MailAddress not reject the email address someName@gmail? 为什么 MailAddress 认为“john@gmail”。 是一个有效的电子邮件地址吗? - Why does MailAddress think 'john@gmail.' is a valid email address?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM