Hi

I am trying to send a reminder mail with the HTML Table format. But the details is not getting displayed. Please help me to fix.

i am using class file to send the email.

include ('config.php');

date_default_timezone_set('Asia/Calcutta'); 

require "classemail.php";

$mail = new EMail;
$mail->Username = 'emailid';
$mail->Password = 'password';

$today_data = '2016-02-03';
$stmt = "SELECT * FROM reminder_scheduler,reminder_execution WHERE RCE15STST='Y' and RCE15SID=EXE15SID and EXE15STST is null and EXE15NXTRDT=?";
$params = array($today_data);
$query = sqlsrv_query( $conn, $stmt, $params);  

 $mContent   = '';
echo $mcontent .=
"<div style='width:600px; margin:0px auto;'>
    <div style='width:560px; height:auto; border-left:1px solid #dfdfdf; border-right:1px solid #dfdfdf; padding:20px 20px; background-color:#f7f7f7; float:left;'>
        <table style='font-family:Arial; font-size:12px;' width='560px' border='0'>
            <tr>
                <td colspan=3>
                    <span style='color:#2A4E98; font-weight:bold;'>Hi</span>
                </td>
            </tr>
            <tr>
                <td align=left colspan=3><span style='font-family:Arial; font-size:12px; color:#000000;text-indent:40px;'></span></td>
            </tr>
            <tr>
                <td align=left colspan=3>&nbsp;</td>
            </tr>
            <tr>
                <td align=left colspan=3><b><u>Reminder for Payment Due :</u></b></td>
            </tr>
            <tr>
                <td align=left colspan=3><span style='font-family:Arial; font-size:12px; color:#000000;text-indent:40px;'></span></td>
            </tr>
            <tr>
                <th align=left width='80'>S.No</th>
                <th align=left width='280'>Vendor Name</th>
                <th align=left width='200'>Payment Due Date</th>
            </tr>
            <tr>
                <td align=left colspan=3>&nbsp;</td>
            </tr>";


                $i=1;
                while($result = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC))
                    {

            "<tr>
                <td style='border-bottom:1px solid #dfdfdf;padding:10px;' height='25'>". $i ."</td>
                <td style='border-bottom:1px solid #dfdfdf;padding:10px;'>". $result['RCE15TITLE']."</td>
                <td style='border-bottom:1px solid #dfdfdf;padding:10px;'>". $result['EXE15NXTDDT']."</td>
            </tr>";

             $i++;} 
        "</table>
    <div style=' float:left; width:541px; height:30px; border-top:3px solid #da251e; background-color:#dfdfdf;border-left:1px solid #c5c5c5; border-right:1px solid #c5c5c5; border-bottom:1px solid #c5c5c5; float:left; line-height:30px; padding-left:15px; font-family:Arial; font-size:10px; color:#828282;'> Copyright ".date('Y')."  Circular Edge, Inc. All rights reserved.</div>
</div>";

    //echo $result["RCE15TITLE"];
    $mail->SetFrom("Sender Email","Text");      // Name is optional
    $mail->AddTo("email","Name");   // Name is optional
    $mail->Subject = 'Payment Reminder for - '.$today_data;
    $mail->Message=$mcontent;
    //Optional stuff
        //$mail->AddCc("ccaddress@example.com","CC Name");  // Set a CC if needed, name optional
        $mail->ContentType = "text/html";               // Defaults to "text/plain; charset=iso-8859-1"
        $mail->Headers['X-SomeHeader'] = 'abcde';       // Set some extra headers if required
        $mail->ConnectTimeout = 30;     // Socket connect timeout (sec)
        $mail->ResponseTimeout = 8;     // CMD response timeout (sec)

        $success = $mail->Send();
        if($success)
        {
            echo "<fieldset>";
            echo "<div id='success_page'>";
            echo "<h1>Email Sent Successfully.</h1>";
            echo "</div>";
            echo "</fieldset>";

        } else {

            echo 'ERROR!';

        }
    //; 

?>

Recommended Answers

All 4 Replies

So, you get the email but not the query contents, correct? Is the $conn resource set in the included config.php file?

Thanks for your reply cereal

$conn resource is working fine.

Ok, at line 16 and 17 you are declaring a variable but then using another one:

$mContent   = '';
echo $mcontent .=

so, set $mcontent = ''; or reverse and fix line 67. Note: this should not preclude the execution of the script, usually it should send a notice for undefined variable mcontent but then it should continue to work.

Try to set error_reporting(-1); in top of the script, to see if you get some errors.

Thanks cereal. I removed 16 and 17 with some changes as below

$mail->Message="<div style='width:600px; margin:0px auto;'><div style='width:560px; height:auto; border-left:1px solid #dfdfdf; border-right:1px solid #dfdfdf; padding:20px 20px; background-color:#f7f7f7; float:left;'><table style='font-family:Arial; font-size:12px;' width='560px' border='0'><tr><td colspan=3><span style='color:#2A4E98; font-weight:bold;'>Hi</span></td></tr>
            <tr>
                <td align=left colspan=3><span style='font-family:Arial; font-size:12px; color:#000000;text-indent:40px;'></span></td>
            </tr>
            <tr>
                <td align=left colspan=3>&nbsp;</td>
            </tr>
            <tr>
                <td align=left colspan=3><b><u>Reminder for Payment Due :</u></b><br><br></td>
            </tr>
            <tr>
                <td align=left colspan=3><span style='font-family:Arial; font-size:12px; color:#000000;text-indent:40px;'></span></td>
            </tr>
            <tr>
                <th align=left width='80'><b>S.No</b></th>
                <th align=left width='280'><b>Vendor Name</b></th>
                <th align=left width='200'><b>Payment Due Date</b></th>
            </tr>
            <tr>
                <td align=left colspan=3>&nbsp;</td>
            </tr>";
        $i=1;
        while($result = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC))
        {

        $mail->Message .="<tr><td style='border-bottom:1px solid #dfdfdf;padding:10px;' height='25'>". $i ."</td><td style='border-bottom:1px solid #dfdfdf;padding:10px;'>". $result['RCE15TITLE']."</td><td style='border-bottom:1px solid #dfdfdf;padding:10px;'>". date("d-m-Y", strtotime($result['EXE15NXTDDT']))."</td></tr>";

         $i++;} 
        $mail->Message .="</table>
    <div style=' float:left; width:541px; height:30px; border-top:3px solid #da251e; background-color:#dfdfdf;border-left:1px solid #c5c5c5; border-right:1px solid #c5c5c5; border-bottom:1px solid #c5c5c5; float:left; line-height:30px; padding-left:15px; font-family:Arial; font-size:10px; color:#828282;'> Copyright ".date('Y')."  All rights reserved.</div>
</div>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.