【问题标题】:Node sendgrid ICAS/ICS invitation节点 sendgrid ICAS/ICS 邀请
【发布时间】:2016-07-06 11:11:51
【问题描述】:

我正在使用 npm sendgrid Node SendGrid GitHub

有了这个,我创建了以下模块:

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 发送这个吗?如果是这样,你能指出我正确的方向吗?

【问题讨论】:

    标签: node.js email sendgrid


    【解决方案1】:

    如果您愿意升级到最新版本的 Node.js SendGrid Client library,您可能会发现 v3 /mail/send 端点使发送日历邀请变得更加容易。

    以下是添加“文本/日历”内容类型的示例:https://github.com/sendgrid/sendgrid-nodejs/blob/master/examples/helpers/mail/example.js#L57

    如果您希望直接使用新的 v3 /mail/send 端点,这里有一些文档:

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

    【讨论】:

    • 示例链接已损坏
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-09
    • 1970-01-01
    • 2021-07-12
    相关资源
    最近更新 更多