使用JavaScript设置发件人名称的Gmail API?

5
我正在使用Gmail APIs发送电子邮件。邮件已成功发送,但是发件人地址并没有像我所说的“Anup S via TestApp”一样显示。相反,它只显示了userID/email。
var email_lines = [];
email_lines.push("From: Anup S via TestApp <username@gmail.com>");
email_lines.push("To: to_user@gmail.com");
email_lines.push('Content-type: text/html;charset=iso-8859-1');
email_lines.push('MIME-Version: 1.0');
email_lines.push("Subject: New future subject here");
email_lines.push("");
email_lines.push("And the body text goes here");
email_lines.push("<b>And the bold text goes here</b>");

var email =email_lines.join("\r\n").trim();


var base64EncodedEmail = btoa(email);
var requestEmail = gapi.client.gmail.users.messages.send({
    'userId': "me", // I also tried changing this - and (obviously) it does not work. 
    'message': {
        'raw': base64EncodedEmail
    }
});

有没有关于如何修复这个问题的想法?
2个回答

1
如何尝试添加 ' 标记?
  email_lines.push("From: 'Anup S via TestApp' <username@gmail.com>");

0

API中的发件人电子邮件地址必须与已登录用户的电子邮件地址匹配,不能是其他人。在您的情况下是否属实?如果是,则您应该能够设置任何您想要的电子邮件显示名称,例如:

email_lines.push("From: \"某个名称\" <myEmailAddr@gmail.com>");


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接