Replies: 2 comments 1 reply
-
Hi @sbleitner,
Here's a raw draft of the config you will have to refine and test to fully match you complex scenario: {
"description": "Example for https://github.com/ahochsteger/gmail-processor/discussions/513",
"settings": {
"markProcessedMethod": "add-label",
"markProcessedLabel": "invoices processed"
},
"global": {
"thread": {
"match": {
"query": "-in:trash -in:drafts -in:spam -in:sent -label:\"invoices processed\" ({invoice order proforma} OR filename:{invoice order proforma})"
}
}
},
"threads": [
{
"description": "Store PDF attachments",
"match": {
"query": "(has:attachment AND filename:pdf)"
},
"messages": [
{
"attachments": [
{
"match": {
"name": "\\.pdf$"
},
"actions": [
{
"name": "attachment.store",
"args": {
"location": "{{message.date|formatDate('MMMM yyyy')}}/{{attachment.name}}",
"conflictStrategy": "keep"
}
}
]
}
]
}
]
},
{
"description": "Store non-PDF attachments converted to PDF",
"match": {
"query": "(has:attachment AND filename:{docx xlsx})"
},
"messages": [
{
"attachments": [
{
"match": {
"name": "\\.(docx|xlsx)$"
},
"actions": [
{
"name": "attachment.store",
"args": {
"location": "{{message.date|formatDate('MMMM yyyy')}}/{{attachment.name}}",
"conflictStrategy": "keep"
}
}
]
}
]
}
]
},
{
"description": "Export emails without attachments to PDF",
"match": {
"query": "-has:attachment"
},
"messages": [
{
"actions": [
{
"name": "message.exportAsPdf",
"args": {
"location": "{{message.date|formatDate('MMMM yyyy')}}/{{message.subject}}.pdf",
"conflictStrategy": "keep"
}
}
]
}
]
}
]
} You can paste this config into the playground to further refine it. Afterwards you can copy the full JavaScript code using the JS icon and paste it into your Google Apps Script file. |
Beta Was this translation helpful? Give feedback.
-
@sbleitner glad to see that it worked for you. :-) The fix for promotional emails seems a good fit since you can build on the trainable auto-categorization features of Gmail. Here are some advices to your remaining issues: To correctly process emails that are attached to a thread you need the possibility to mark individual emails as processed, which is not possible with labels, since they are attached on the thread-level. A solution would be to use the read status that can be set for each email individually. Therefore you have to switch the Concerning the unprocessed uppercase letters in file extensions I suggest to adjust the regex with the file names (e.g. I hope this helps you to fix your remaining issues. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm a basic user, so I find it difficult to create a config file for anything more than just a basic use scenario.
Right now I'm trying to use this script for the following scenario:
{invoice, order, proforma}
in the subject, body, or attachments.(.XLSX, .DOCX, etc.)
, convert it to PDF before saving it to the folder.If anyone has a similar use scenario, would you kindly share this with the community so I can tweak it to my own requirements?
TIA
S
Beta Was this translation helpful? Give feedback.
All reactions