简体   繁体   English

使用System.Net.Mail.SmtpClient将电子邮件发送到通讯组列表

[英]Sending email to a distribution list using System.Net.Mail.SmtpClient

I'm sending email to a distribution list using System.Net.Mail.SmtpClient Here is the method I use. 我正在使用System.Net.Mail.SmtpClient将电子邮件发送到通讯组列表这是我使用的方法。 xyz@domain.com is the distribution list. xyz@domain.com是通讯组列表。

var strMailServer = ConfigurationManager.AppSettings["MailServer"];
var fromAddress = new MailAddress("abc@domain.com");
var bodyMsg = "BodyText;
var message = new MailMessage();
var smtpClient = new SmtpClient(strMailServer)
{
    Credentials = new NetworkCredential("", ""),
    Port = 25,
    EnableSsl = true
};

message.From = fromAddress;
message.To.Add("xyz@domain.com");
message.Subject = _context.Fields["Subject"].Value;
message.IsBodyHtml = true;
message.Body = bodyMsg;
smtpClient.Send(message);

The mail is not delivered to xyz@domain.com distribution list. 邮件未传递到xyz@domain.com分发列表。 Am I missing something? 我想念什么吗?

创建通讯组列表时,取消选中“要求所有发件人都经过身份验证”

If you are using a username and password other than your windows credentials, you need to set UseDefaultCredentials to false before providing the new credentials: 如果您使用的用户名和密码不是Windows凭据,则需要提供新凭据之前UseDefaultCredentials设置为false:

var smtpClient = new SmtpClient(strMailServer)
{
    UseDefaultCredentials = false,
    Credentials = new NetworkCredential("", ""),
    Port = 25,
    EnableSsl = true
};

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

相关问题 使用System.Net.Mail.SmtpClient发送的电子邮件的字体大小 - Font size for an email sent using System.Net.Mail.SmtpClient 如何在Xamarin中使用System.Net.Mail.SmtpClient发送邮件 - How to send a mail in Xamarin using System.Net.Mail.SmtpClient System.Net.Mail.SmtpClient 在发送电子邮件时使用什么类型的身份验证? - What type of authentication is System.Net.Mail.SmtpClient using when sending emails? 使用System.Net.Mail.SmtpClient,更改SMTP FROM电子邮件地址 - Using System.Net.Mail.SmtpClient, change the SMTP FROM email address 无法使用 System.Net.Mail.SmtpClient 将 email 发送到其他域 - Unable to send email to other domains using System.Net.Mail.SmtpClient System.Net.Mail.SmtpClient 在 4.7 中过时了吗? - Is System.Net.Mail.SmtpClient obsolete in 4.7? 使用TLS和SmtpAuth在.Net 4 / C#中发送带有System.Net.Mail.SmtpClient的电子邮件,可在本地使用,但不能在生产服务器上运行(win 2008 r2) - Sending email with System.Net.Mail.SmtpClient in .Net 4/C# with TLS and SmtpAuth, works locally but not on production server(win 2008 r2) 第三方与System.Net.Mail.SmtpClient - Third-party vs System.Net.Mail.SmtpClient 发送到 System.Net.Mail.SmtpClient 等文件夹 - Send to folder like System.Net.Mail.SmtpClient 如何使用TLS和System.Net.Mail.SMTPCLient连接到googlemail.com? - How can I connect to googlemail.com using TLS and System.Net.Mail.SMTPCLient?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM