How do I email Active Directory distribution groups from a c# web application?

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

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.

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

Thanks

Answers


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


Need Your Help

jQuery wait till all page animations are done

jquery animation promise

I know how to wait till an animation is done with

Can Visual Studio 2010 work with classic ASP include files?

visual-studio visual-studio-2010 asp-classic

I'm testing VS 2010 with a classic ASP VBScript site I have to work on. It can auto complete and show reference for user functions. However it doesn't analyze 'include' files, so library functions ...

Adding REST to Django

python django apache rest

I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.