How to access date/time of emails using appscript

丶灬走出姿态 提交于 2019-12-20 05:21:32

问题


I'm looking at my inbox and I can see the time of the email is being recorded, but I'm having trouble seeing how to grab the date/time of an email, despite looking at the apps script gmail API (https://developers.google.com/apps-script/reference/gmail/gmail-app?hl=ja#detailed-documentation)

Can this be done?


回答1:


How about a following sample? You can retrieve date for each e-mail using getDate(). The sample script is as follows.

Sample script :

var threads = GmailApp.getInboxThreads(0, 50);
threads.forEach(function(messages){
  messages.getMessages().forEach(function(msg){
    var date = msg.getDate(); // date/time
    var body = msg.getBody(); // mail
    Logger.log(date)
    Logger.log(body)
  });
});
  • The information of getDate() is here
  • The information of getInboxThreads() is here

If I misunderstand your question, I'm sorry.



来源:https://stackoverflow.com/questions/45948541/how-to-access-date-time-of-emails-using-appscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!