Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing SQL query result as Parameter for sending Email using Perl
    primarykey
    data
    text
    <p>I want to retrieve the email address from the table and using that to send email using perl script.</p> <p>How to use the query result in mail. I am new to perl scripting please help.</p> <p>I have updated as suggested but still there are some issues. Please tell me where I am going wrong.</p> <p>Thanks in advance.</p> <pre><code>#!/usr/bin/perl # $Id: outofstockmail.pl,v 1.0 2012/03/01 21:35:24 isha Exp $ require '/usr/home/fnmugly/main.cfg'; use DBI; my $dbh = DBI-&gt;connect($CFG{'mysql_dsn'},$CFG{'mysql_user'}, $CFG{'mysql_password'}) or &amp;PrintError("Could not connect to the MySQL Database.\nFile could not be made!\n"); $dbh-&gt;{RaiseError} = 1; # save having to check each method call print "&lt;H1&gt;Hello World&lt;/H1&gt;\n"; $sql = "Select OS.name, OS.customer_email, OS.product, OS.salesperson, OS.salesperson_email from products AS P LEFT JOIN outofstock_sku AS OS ON OS.product = P.sku LEFT JOIN tech4less.inventory AS I ON (I.sku = P.sku AND I.status = 'A') WHERE mail_sent='0' GROUP BY OS.product"; #$sth = $dbh-&gt;do($sql); my $sth1 = $dbh-&gt;prepare($sql); $sth1-&gt;execute; while ( my @row = $sth1-&gt;fetchrow_array ) { # email open MAIL, "| $mail_prog -t" || die "Could not connect to sendmail."; print MAIL "To: $row[1]"; print MAIL "From: $row[4]"; print MAIL "Reply-To:$row[4]"; print MAIL "CC: $row[4]"; print MAIL "Subject: Product requested is back in inventory\n"; print MAIL "\n"; print MAIL "Hi $row[0] , The product $row[2] is available in the stock.\n"; print MAIL "\n"; close MAIL; $sql = "Update outofstock_sku SET mail_sent='0' WHERE mail_sent='1'"; $sth2 = $dbh-&gt;do($sql); } $sth = $dbh-&gt;do($sql); $dbh-&gt;disconnect(); exit; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload