Kiko has asked for the wisdom of the Perl Monks concerning the following question:
Hey, I have an access database that contains several id's that needs to be e-mailed to several different people. I wrote a script to retrieve the id's from the database and e-mail them to the specific user. Unfortunately, it's not working. i have a file in which i'm writing the message to and then e-mailing it. But, the program is trying to open or create all the files at the same time, and then it can't close them. what i want to do is create one file and write to it, then e-mail that file, and so on until all the ids have been e-mailed. Here is what i have thus far: #!/perl/bin/perl use Win32::ODBC; use win32; use CGI qw(:standard); ### Connect to the database $db=new Win32::ODBC("DSN=bisdata;UID=;PWD="); ### Sql statement my $statement="SELECT web_id, country, mail_alias FROM lexnex_ids"; ### report connection status if (!$db) { print "\nunable to connect to database!"; die(); } $num=0; ### Test to see if the person is in the US, if so send him ### an e-mail with his ID $db->Sql("$statement"); while ($db->FetchRow()) { my (%dbrow) = $db->DataHash(); my $place=$dbrow{'country'}; @tester=keys %dbrow; if ($place eq US){ ### Sql statement my $statement="SELECT web_id, country, mail_alias FROM lexnex_ids" +; ### Retrieve the records and place it in a hash array $db->Sql("$statement"); while ($db->FetchRow()) { my (%dbrow) = $db->DataHash(); my $lexid=$dbrow{'web_id'}; my $lexuser=$dbrow{'mail_alias'}; @tester=keys %dbrow; ### Needed to send e-mail $mailprog='d:\WEBSVR\blat\blat.exe'; $recipient='-t $lexuser@comp.com -f kilo@comp.com'; $nice="d:/WEBSVR/test/Completed/ProgCom/CdromDB_Files/lexnex_i +d$num.txt"; $subject="-s Your Nexis Universe ID"; ### Opens the file to place content to be e-mailed open (F, ">$nice"); print F "Your User ID is: $lexid. Your password is your last +name.\n\n"; close(F) || print p("can't close $nice"); $commandline="$mailprog $nice $recipient $subject -q"; system("$commandline"); $num = $num + 1; } } } ### If there is an error, print it print "\n"; print $db->Error(); ### Close ODBC connection $db->Close(); Thanks, Kiko
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(chromatic) Re: Mass Mail
by chromatic (Archbishop) on Jul 12, 2000 at 21:19 UTC | |
|
Re: Mass Mail
by ZZamboni (Curate) on Jul 12, 2000 at 21:59 UTC | |
|
Re: Mass Mail
by splinky (Hermit) on Jul 12, 2000 at 21:10 UTC | |
|
Re: Mass Mail
by Kiko (Scribe) on Jul 13, 2000 at 01:49 UTC | |
by Corion (Patriarch) on Jul 13, 2000 at 12:29 UTC | |
by chromatic (Archbishop) on Jul 14, 2000 at 06:46 UTC |