How can I email Active Directory distribution groups from a C # web application?

I am trying to send email to Active Directory distribution groups.

I know that 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 to a (valid) AD group (like "My Test Group") in the box To

, it throws it out because it's not a valid email address.

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

thank

+1


source to share


1 answer


Your distribution group has a mailing address that you need to add to the 'to' parameter.



+2


source







All Articles