发送带有angularJs附件的电子邮件?

时间:2017-01-02 15:20:25

标签: javascript angularjs email

我使用$window.open()向特定目的地发送电子邮件,但我无法通过附件或嵌入图片发送电子邮件。

我有这样的事情:

$window.open('mailto:xxx@xxx.xx?subject=Subject&body=Body&attachment=http://images0.minutemediacdn.com/production/912x516/57ea81dce8f2a0c893000001.jpg');

有没有解决这个问题并发送带有该图片的电子邮件(嵌入或附加)?

1 个答案:

答案 0 :(得分:2)

您无法直接使用javascript发送电子邮件。您只能打开用户的邮件客户端:

<?php
    $dtpickerdate = isset($_GET['dtpickerdate']) ? $_GET['dtpickerdate'] : "2016-06-06";
    $con = pg_connect("dbname=patient user=spo password=secretpass") or die("db connection failed!");
    $d1 = (string)strtotime($dtpickerdate.' 12:00:00');
    $nday = (int)substr($dtpickerdate, -2) + 1;
    $ndat = substr($dtpickerdate, 0, 8).(string)$nday;
    $d2 = (string)strtotime($ndat.' 12:00:00');
    $sth = pg_query($con, "select * from stats where utc between ".$d1." and ".$d2);
    $table['cols'] = array(
        array(id => 'utc', label => 'Time', type => 'datetime'),
        array(id => 'spo', label => 'spO2', type => 'number'),
        array(id => 'hr', label => 'PulseRate', type => 'number')
    );
    while($r = pg_fetch_assoc($sth)) {
        $temp = array();
        $mon = (int)date("m", $r['utc']) - 1;
        $mdat = "Date(".date("Y, ", $r['utc']).(string)$mon.date(", d, H, i, s)", $r['utc']);
        $temp[] = array(v => (string) $mdat);
        $temp[] = array(v => (int) $r['spo']);
        $temp[] = array(v => (int) $r['hr']);
        $rows[] = array(c => $temp);
    }
    $table['rows'] = $rows;
    $json = json_encode($table);
    //echo $json;
?>

<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
    google.charts.load('current', {'packages':['corechart']});
    google.charts.setOnLoadCallback(drawChart);
    function drawChart() {
      var data = new google.visualization.DataTable(<?=$json?>);
      var options = {
                    chartArea: {'width': '92%', 'height': '86%'},
                    title: 'spO2/hr monitor',
                    legend: { position: 'bottom' },
                    vAxis: {viewWindow:{max:100, min:50}, gridlines:{count:6}, minorGridlines:{count:4}},
                    hAxis: {
                        gridlines: {
                            count: -1,
                            units: {
                                days: {format: ['MMM dd']},
                                hours: {format: ['HH:mm', 'ha']},
                            }
                        },
                        minorGridlines: {
                            units: {
                                hours: {format: ['hh:mm:ss a', 'ha']},
                                minutes: {format: ['HH:mm a Z', ':mm']}
                            }
                        }
                    }
                };
      var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
      chart.draw(data, options);
    }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 100%; height: 100%"></div>
  </body>
</html>

还有一些参数可以预先填充主体和身体: