2016-07-06 5 views
0

ノードsendgrid ICAS/ICSの招待状:私ができる招待状を送りたい私のメールのいくつかのために今私は、次のモジュールを作成しているこれでNPM <code>sendgrid</code><a href="https://github.com/sendgrid/sendgrid-nodejs" rel="nofollow">node sendgrid github</a></p> <p>を使用しています

var path = require('path'), 
    emailTemplates = require('email-templates'), 
    async = require("async"), 
    mailConfig = require('../config/email.json'), 
    templates = require('../config/emailTemplates.json'), 
    _ = require('lodash'), 
    sendgrid = require('sendgrid')(mailConfig.sendGridApiKey), 
    fs = require("fs"); 
    var mymailer = {}; 

/** 
* Sends an email to either one or multiple users 
* @param template_id (The id key of the template. Can be found in emailTemplates.json 
* @param to String or Array 
* @param from String 
* @param subject String 
* @param keyReplacer Array of objects for keys to replace in the template 
* @param files Array of file objects 
*/ 
mymailer.sendTemplate = function (template_id, to, from, subject, keyReplacer, section, text, files) { 
    var email = new sendgrid.Email(), templateKey = templates[template_id]; 

    if (templateKey) { 
     email.setSmtpapiTos(to); 
     email.subject = subject; 
     email.from = from; 
     email.text = text; 
     email.html = 'Gief HTML NU:D'; 
     email.setFilters({ 
      "templates": { 
       "settings": { 
        "enable": 1, 
        "template_id": templateKey 
       } 
      } 
     }); 
     email.smtpapi.header.sub = prepareSub(keyReplacer, section); 
     email.smtpapi.header.section = prepareSection(section); 
     email.files = prepareAttachement(files); 
     sendgrid.send(email); 
    } else { 
     console.log('incorrect key'); 
    } 
}; 

をあなたのカレンダーで受け入れられます。しかし、私はこれを行う方法がわからないし、私はその件についての情報を見つけることができません。

誰かがsendgridを使ってこれを送信しようとしましたか?もしそうなら、正しい方向に私を向けることができますか?

答えて

2

Node.js SendGrid Client libraryの最新バージョンにアップグレードしたい場合は、v3/mail/sendエンドポイントでカレンダーの招待状を送信しやすくなります。ここで

は「テキスト/カレンダー」のコンテンツタイプを追加する例である:ここでhttps://github.com/sendgrid/sendgrid-nodejs/blob/master/examples/helpers/mail/example.js#L57

は、新しいV3 /メールでのいくつかのドキュメント/あなたは、むしろそれを直接使用する場合は、エンドポイントを送っている:

https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/index.html https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html

関連する問題

 関連する問題