问题
MailApp.sendEmail({
to: " someemail@gmail.com , ",
subject: "New change for " + variable1+ " at " + variable2,
htmlBody: "Added: " + addedlist_new.toString() + "<br><br>" +
"Removed: " + removedlist_old.toString() + "<br><br>" +
" https://docs.google.com/spreadsheets/d/someurlhere ",
})
When I have an email directed to a user other than myself, I find that I end up having the email that was sent to them, in my inbox. It shows it's sent to the user I entered in the "To" area, but it's in my inbox. Why does it place it in my Inbox instead of Sent Mail?
回答1:
Try this way:
var toEmail = "someemail@gmail.com";
var subject = "New change for " + variable1+ " at " + variable2;
var messageBody = "Added: " + addedlist_new.toString() + "<br><br>" + "Removed: " + removedlist_old.toString() + "<br><br>" + "https://docs.google.com/spreadsheets/d/someurlhere";
MailApp.sendEmail(toEmail , subject , "" , {htmlBody: messageBody});
回答2:
I had this problem and found that replacing Mailapp.sendEmail with Gmailapp.sendEmail worked.
来源:https://stackoverflow.com/questions/42139251/mailapp-sendemail-sending-email-to-myself-when-not-set-to-in-google-apps-script