I'm looking for a script that will search the body text of emails from a specific sender, find a string of text in the email, such as "You'll receive: US$7.16", then take the number 7.16 and add it to a Google Doc spreadsheet where it would be broken down showing the total for the day, week, month, year. Does anything like this exist, or something like it that could be modified?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You could start with the example in How to use Google App Scripts to retrieve Gmail emails in a customised way? (Author even states "Here's a neat javascript code I wrote to get all emails from my Gmail and put the list of sender name in a google spreadsheet.")
From there, you could identify messages from the particular sender you're interested in. (Alternatively, you could use GMail filters to label the email from that sender, then use getUserLabelByName() to grab the threads without requiring a search.)
Once you have the threads & messages, you can grab the mail content as a string using getPlainBody(), from which you can retrieve the monetary values. How does one find the currency value in a string?