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

In reply to Mass Mail by Kiko

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.