如何通过c#Web应用程序向Active Directory通讯组发送电子邮件?

时间:2022-07-06 07:32:47

I'm trying to send email to Active Directory distribution groups.

我正在尝试向Active Directory通讯组发送电子邮件。

I know you can send mail using something like:

我知道您可以使用以下内容发送邮件:

 mail.From = new MailAddress("steveb@microsoft.com");
 mail.To.Add("billg@microsoft.com");

 //set the content
 mail.Subject = "This is an email";
 mail.Body = "this is a sample body with html in it.";
 mail.IsBodyHtml = true;

 //send the message
 SmtpClient smtp = new SmtpClient("127.0.0.1");
 // i seem to need this too....
 smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
 smtp.Send(mail);

But when I try to stick in a (valid) AD group (eg "My Test Group") in the To field, it kicks it out because it is not a valid email address.

但是当我尝试在To字段中坚持(有效)AD组(例如“我的测试组”)时,它会将其解雇,因为它不是有效的电子邮件地址。

I'm sure this is really straightforward, but I seem to be stuck...

我确信这真的很简单,但我似乎被卡住了......

Thanks

1 个解决方案

#1


2  

You distribution group has a mail address, that's what you need to add in the 'to' parameter.

您的通讯组有一个邮件地址,这是您需要在'to'参数中添加的内容。

#1


2  

You distribution group has a mail address, that's what you need to add in the 'to' parameter.

您的通讯组有一个邮件地址,这是您需要在'to'参数中添加的内容。