Created
August 18, 2022 11:40
-
-
Save omas-public/cfbc8e7905922b30f097358f7583e221 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createInfo = (start, max) => { | |
const threads = GmailApp.getInboxThreads(start, max) | |
const matrix = threads.map(v => ( | |
[ | |
v.getId(), | |
v.getFirstMessageSubject(), | |
v.getMessageCount() | |
] | |
)) | |
return matrix | |
} | |
const createSpread = (matrix, filename = 'default') => { | |
const ss = SpreadsheetApp.create(filename) | |
const range = ss.getActiveSheet() | |
.getRange(...[1, 1], matrix.length, matrix[0].length) | |
range.setValues(matrix) | |
return ss.getId() | |
} | |
const sendMail = (recipient, subject, matrix) => { | |
const body = matrix.map(v => v.join(' ')).join('\n') | |
GmailApp.sendEmail(recipient, subject, body) | |
} | |
const main = () => { | |
const matrix = createInfo(10, 3) | |
// const id = createSpread(matrix, '0818') | |
sendMail( | |
'[email protected]', | |
'mail info', | |
matrix | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment