如何使用google-api-nodejs-client为nodejs发送带有gmail api附件的邮件 [英] How to send a mail with an attachment in gmail api using google-api-nodejs-client for nodejs

查看:671
本文介绍了如何使用google-api-nodejs-client为nodejs发送带有gmail api附件的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我为node.js使用google-api-nodejs-client。

我希望通过gmail发送附件。

我当前的消息发送代码是:

  var gmailClass = google.gmail(' V1' ); 
gmailClass.users.messages.send({
auth:OAuth2Client,
userId:'me',
resource:{
raw:base64EncodedEmail
} ,
}
,函数(err,results)
{
if(!err)
{
//做某事
}
else
{
//做某事
}
});

有没有办法将附件添加到发送功能?

解决方案

你的附件应该在你已经使用的rawbase64EncodedEmail中。格式只是一个完整的电子邮件信息(例如,查看Gmail或任何其他邮件客户端中的显示原始信息以查看具有附件的电子邮件的外观)。我想有一些MIME电子邮件消息库会有帮助...


I wish to send an email with an attachment through gmail.

I'm using google-api-nodejs-client for node.js.

My current message sending code is:

var gmailClass = google.gmail('v1');
gmailClass.users.messages.send({
            auth: OAuth2Client,
            userId: 'me',
            resource: {
              raw: base64EncodedEmail
            },
          }
        ,function(err, results)
        {
        if (!err)
        {
          //do something    
        }
        else
        {
          //do something
        }
});

Is there a way to add an attachment to the send function?

解决方案

Your attachment should be in the "raw" base64EncodedEmail you're already using. The format is simply a full email message (e.g. look at "Show Original" in Gmail or any other mail client to see what an email with an attachment looks like). I imagine there are some MIME email message libraries that will be helpful...

这篇关于如何使用google-api-nodejs-client为nodejs发送带有gmail api附件的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆