views:

1040

answers:

2

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

I know you can send mail using something like:

 mail.From = new MailAddress("[email protected]");
 mail.To.Add("[email protected]");

 //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

+1  A: 

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

Nico
I suspected this might be the case, now if only I could find it :D
DrG
ARGH my group isn't a Distribution Group... that's why it was being stupid.
DrG
Correct, you either have to use distribution group or email enabled security group.
Nico
A: 

For the record, Nico is 100% correct, my sysadmin guys created a test group for me but they created a Global User Group and not a Distribution Group as requested.

They claimed they were testing me :D

In fact it cost me 2 hours of my life.

DrG