预填充到发件箱的Outlook邮件窗口不起作用

时间:2019-02-07 18:37:42

标签: javascript php function outlook

errors i get

我有一张表格,其中包含详细信息,其中之一是电子邮件。当我单击一个链接时,我打开了Outlook邮件,但我想将表格中该行的电子邮件放入电子邮件的“收件人”部分。下面我有我目前正在做的代码。

下面的代码以表格格式显示数据库中的数据

 <table class="table table-striped custab">
           <thead>
            <tr>
            <th> </th>
            <th>Booking ID</th>
	    <th> Name</th>
            <th>Email</th>
	    <th>Date</th>
	    <th>time</th>
	    <th>No. of guests</th>
            <th>Booking Reason</th>
            <th>Comments</th>
	    <th width="110" class="ac">Approved?</th>
	    </tr> 
           <thead>
             <!-- php function to only select the bookings that have not yet been approved/rejected -->
             <?php
		include 'config.php';
		$select = "SELECT * FROM `booking` WHERE `status`IS NULL ";
		$result = $conn->query($select);
		while($row = $result->fetch_assoc()){
	     ?>
            <tr>
		<td><input type="checkbox" class="checkbox" /></td>
                <td><?php echo $row['customer_ID'] ?></td>
		<td><?php echo $row['Name'] ?></td>
		<td><?php echo $row['Email'] ?></td>
		<td><?php echo $row['booking_date'] ?></td>
		<td><?php echo $row['booking_time'] ?></td>
                <td><?php echo $row['attendee_no'] ?></td>
                <td><?php echo $row['booking_reason'] ?></td>
                <td><?php echo $row['comments'] ?></td>
                
                <td>
            <a href="#" onclick="javascript:TriggerOutlook(<?php echo $row['Email'];?>)" value="submit">Email this Codesnippet</a></a>
            </td>
            
            
            </tr>
                 <?php
	            }
		?>
        </table>  

以下功能会弹出以显示Outlook邮件

<script  type="text/javascript"> TriggerOutlook(Email)

    {    
    
		var $to      = 'Email';
		var body = "your booking has been approved";
        <!-- var body = escape(window.document.title + String.fromCharCode(13)+ window.location.href);        --->

        var subject = "Your booking request";

                        window.location.href = "mailto:?body="+body+"&to="+$to+"&subject="+subject;               

            }   

    </script>

如果我手动将一封电子邮件放入var $ to =前景弹出窗口中,但是如果我尝试从表中获取该电子邮件却没有,有人可以帮助我确定我要去哪里吗?谢谢!

1 个答案:

答案 0 :(得分:0)

1您不需要变量的PHP $声明,因此:

var $to      = 'Email';

应为:

var to      = 'Email';

更多描述性变量可以使将来的更新更容易:

var toAddr      = 'Email';

2您的JavaScript函数应带有功能标签

<script  type="text/javascript"> TriggerOutlook(Email)

{    

更改为:

<script  type="text/javascript"> 
function TriggerOutlook(Email){    

3使用按钮而不是链接

替换 <a href="#" onclick="javascript:TriggerOutlook(<?php echo $row['Email'];?>)" value="submit">Email this Codesnippet</a></a>

使用

<button 
    onclick="TriggerOutlook(<?php echo $row['Email'];?>)" 
    value="submit"
    >Email this Codesnippet</button>