2017-09-27 20 views
0

私は1人以上の人に電子メールを送ろうとしています。私のコードはnode.jsにあり、私は送付状を使っています。カンマで区切っても機能しません。また、電子メールの内容をHTMLタグを知っているhtml形式にしたい。複数のメールアドレスにメールを送信

これらは、文字列の配列として電子メールを送信する必要がある複数のユーザーに電子メールを送信するために私のコード

let html = "<b>"+"Hi John and Dee! </br>Someone needs help from a 
CultureMee Consultant!</br>" + "Name: " +name + "</br>"+ "Email: " 
+email+ "</br>"+ "Phone: " +phone +"</br>"+"Organisation: 
"+organisation+"</b>"+ "How can you help: " +howCanWeHelp +"</br>" 
+"Good luck!</b>" 
//let html ="hello" 

var helper = require('sendgrid').mail; 
var from_email = new helper.Email(email); 
var to_email = new 
helper.Email("[email protected],[email protected],[email protected] 
apps.com"); 
var subject = "There is a new CultureMee Consultant Application"; 
var content = new helper.Content('text/plain', html); 
var mail = new helper.Mail(from_email, subject, to_email, content); 



var sg = require('sendgrid')(process.env.SENDGRID_API_KEY); 
var request = sg.emptyRequest({ 
    method: 'POST', 
    path: '/v3/mail/send', 
    body: mail.toJSON() 
}); 

sg.API(request, function (error, response) { 
    if (error) { 
    console.log('Error response received'); 
    } 
    console.log(response.statusCode); 
    console.log(response.body); 
    console.log(response.headers); 
}); 

答えて

1

です。だからあなたのようなものを使ってメールを追加することができます。

to: [ 
    { 
    email: '[email protected]', 
    }, 
    { 
    email: '[email protected]', 
    }, 
], 

をさらに詳細な例はthisthisを確認してください。

+0

このようにこの部分を書く必要がありますか? var to_email = new helper.Email([{email:[email protected]}、{email:[email protected]}、{email:[email protected] apps.com}]); – Mehr

+0

はい試してみてください –

関連する問題