Important alert: (current site time 7/15/2013 9:30:35 PM EDT)
 

VB icon

Email all users in domain

Email
Submitted on: 7/30/2000 12:43:50 AM
By: Found on the World Wide Web 
Level: Intermediate
User Rating: Unrated
Compatibility: 5.0 (all versions), 4.0 (all versions), 3.0 (all versions), Pre 3.0
Views: 9276
 
     This script grabs a list of all the users in a domain and emails the results to an email address.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
=**************************************
= Name: Email all users in domain
= Description:This script grabs a list of all the users in a domain and emails the results to an email address.
= By: Found on the World Wide Web
=**************************************

use strict;
use Win32::NetAdmin;
use Net::SMTP;
my $dc = "\\\\x";
my $from = 'x@x.com';
my @recip_list = ('x@x.com', 'y@y.com');
my $smtp_host = "x.x.x.x";
my @users = ();
my $VERSION = "1.2";
my $smtp = Net::SMTP->new($smtp_host, Timeout => 30) || die "Can't connect to $smtp_host.\n";
$smtp->mail($from) || die "cannot mail from.\n\n";
$smtp->recipient(@recip_list);	
$smtp->data();
$smtp->datasend("To:\tPerl Recipients\n");
$smtp->datasend("Subject:\tPerl output of Users in the domain\n\n");
Win32::NetAdmin::GetUsers($dc, undef, \@users) || die "GetUsers failed.\n";
foreach (@users) {
$smtp->datasend( "$_\n\n");
}
$smtp->dataend;
$smtp->quit;
=head1 NAME
adminmail - This script grabs a list of all the users in a domain and emails the results to an email address.
=head1 DESCRIPTION
This program is useful for quickly getting a list of all the users on your domain. I wrote this program when our Notes 
administrator "Maddog" needed a list of users on the domain.
=head1 README
This script grabs a list of all the users in a domain and emails the results to an email address.
=head1 PREREQUISITES
This script has a few requirements. You will need the Win32::NetAdmin and Net::SMTP modules.
You will also need to change the values for dc, from, recip_list, and smtp_host.
=head1 COREQUISITES
None
=pod OSNAMES
MSWin32
=pod SCRIPT CATEGORIES
Win32/Utilities 
=cut


Other 100 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
7/16/2001 11:30:10 AMmad-hatter

where can i get the Win32::NetAdmin and Net::SMTP modules?
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.