Skip to content

Instantly share code, notes, and snippets.

@omas-public
Created August 18, 2022 11:40
Show Gist options
  • Save omas-public/cfbc8e7905922b30f097358f7583e221 to your computer and use it in GitHub Desktop.
Save omas-public/cfbc8e7905922b30f097358f7583e221 to your computer and use it in GitHub Desktop.
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