Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help - Converting emails to pdf's #75

Closed
boatmon0 opened this issue Jan 11, 2023 · 2 comments
Closed

Help - Converting emails to pdf's #75

boatmon0 opened this issue Jan 11, 2023 · 2 comments
Labels

Comments

@boatmon0
Copy link

I have working stripping attachments and putting them in a folder. I am hoping to convert the email to a pdf and save that pdf to a folder on google drive. I appreciate any help/suggestions.

Eugene

Execution log:
8:26:53 AM
Notice
Execution started
8:26:54 AM
Info
INFO: Starting mail attachment processing.
8:26:54 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam to:[email protected] -label:to-gdrive/processed newer_than:2m
8:26:54 AM
Info
INFO: Processing thread: test of word document (runtime: 0.145s/280s)
8:26:54 AM
Info
INFO: Processing message: test of word document (185a0f1b07b5c7c3)
8:26:54 AM
Info
INFO: Processing attachment: 2022 08 25 Board meeting agenda.docx
8:26:54 AM
Info
Saving to folderScans/2023-01
8:26:57 AM
Info
TypeError: Cannot read properties of undefined (reading 'replace')
8:26:57 AM
Info
INFO: Processing attachment: 2022-07-05 ARCF Fund Balances Account.xlsx
8:26:57 AM
Info
Saving to folderScans/2023-01
8:26:58 AM
Info
TypeError: Cannot read properties of undefined (reading 'replace')
8:26:58 AM
Info
INFO: Processing attachment: 02- Susan Bristow.jpg
8:26:58 AM
Info
Saving to folderScans/2023-01
8:27:02 AM
Info
TypeError: Cannot read properties of undefined (reading 'replace')
8:27:03 AM
Info
INFO: Processing thread: test 2 (runtime: 8.44s/280s)
8:27:03 AM
Info
INFO: Processing message: test 2 (1859e813b2e913ed)
8:27:03 AM
Info
INFO: Processing attachment: Go Daddy My Account Security.pdf
8:27:03 AM
Info
Saving to folderScans/2023-01
8:27:05 AM
Info
TypeError: Cannot read properties of undefined (reading 'replace')
8:27:05 AM
Info
INFO: Processing thread: email attachment test (runtime: 11.313s/280s)
8:27:05 AM
Info
INFO: Processing message: email attachment test (1859cacd97d0341e)
8:27:06 AM
Info
INFO: Processing attachment: 2022 AAoC Tax filing01102023.pdf
8:27:06 AM
Info
Saving to folderScans/2023-01
8:27:08 AM
Info
TypeError: Cannot read properties of undefined (reading 'replace')
8:27:09 AM
Info
INFO: Processing thread: test (runtime: 14.685s/280s)
8:27:09 AM
Info
INFO: Processing message: test (1859c8ac98d0b3bb)
8:27:09 AM
Info
INFO: Processing attachment: 2022 AAoC Tax filing01102023.pdf
8:27:09 AM
Info
Saving to folderScans/2023-01
8:27:12 AM
Info
TypeError: Cannot read properties of undefined (reading 'replace')
8:27:12 AM
Info
INFO: Processing thread: Tax filing requirements (runtime: 17.974s/280s)
8:27:12 AM
Info
INFO: Processing message: Tax filing requirements (1859c83b90207a99)
8:27:12 AM
Info
INFO: Processing attachment: 2022 AAoC Tax filing 201102023.pdf
8:27:12 AM
Info
Saving to folderScans/2023-01
8:27:15 AM
Info
TypeError: Cannot read properties of undefined (reading 'replace')
8:27:15 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam from:[email protected] -label:to-gdrive/processed newer_than:2m
8:27:15 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam to:[email protected] -label:to-gdrive/processed newer_than:2m
8:27:15 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam from:[email protected] -label:to-gdrive/processed newer_than:2m
8:27:15 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam from:[email protected] -label:to-gdrive/processed newer_than:2m
8:27:16 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam from:[email protected] -label:to-gdrive/processed newer_than:2m
8:27:16 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam has:attachment (from:[email protected] OR from:[email protected]) -label:to-gdrive/processed newer_than:2m
8:27:16 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam to:[email protected] -label:to-gdrive/processed newer_than:2m
8:27:16 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam to:[email protected] -label:to-gdrive/processed newer_than:2m
8:27:16 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam has:attachment from:[email protected] -label:to-gdrive/processed newer_than:2m
8:27:16 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam receipt from:[email protected] -label:to-gdrive/processed newer_than:2m
8:27:16 AM
Info
INFO: Processing rule: has:attachment -in:trash -in:drafts -in:spam to:[email protected] -label:to-gdrive/processed newer_than:2m
8:27:16 AM
Info
INFO: Finished mail attachment processing after 22.278s
8:27:16 AM
Notice
Execution completed

My config file:
/**

  • Configuration for Gmail2GDrive
  • See https://github.com/ahochsteger/gmail2gdrive/blob/master/README.md for a config reference
    /
    function getGmail2GDriveConfig() {
    return {
    // Global filter
    "globalFilter": "has:attachment -in:trash -in:drafts -in:spam",
    // Gmail label for processed threads (will be created, if not existing):
    "processedLabel": "to-gdrive/processed",
    // Sleep time in milli seconds between processed messages:
    "sleepTime": 100,
    // Maximum script runtime in seconds (google scripts will be killed after 5 minutes):
    "maxRuntime": 280,
    // Only process message newer than (leave empty for no restriction; use d, m and y for day, month and year):
    "newerThan": "2m",
    // Timezone for date/time operations:
    "timezone": "GMT",
    // Processing rules:
    "rules": [
    { // Store all attachments sent to [email protected] to the folder "Scans"
    "filter": "to:[email protected]",
    "folder": "'Scans/'yyyy-MM"
    },
    { // Store all attachments from [email protected] to the folder "Examples/example1"
    "filter": "from:[email protected]",
    "folder": "'Examples/example1'"
    },
    { // Store all attachments sent to [email protected] to the folder "Scans" with extend received dates
    "filter": "to:[email protected]",
    "folder": "'Scans'-yyyy-MM-dd",
    "newerThan": "3m" // received in the last 3 months (applied for this rule only)
    },
    { // Store all pdf attachments from [email protected] to the folder "Examples/example2"
    "filter": "from:[email protected]",
    "folder": "'Examples/example2'",
    "filenameFromRegexp": ".
    .pdf$"
    },
    { // Store all attachments from [email protected] to the SHARED Drive folder "Shared Drives/Lambda/Examples/example1"
    "parentFolderId": "FOLDER_ID_FOR_Lambda_FOLDER", // This approach is with the ID of "Lambda"
    "filter": "from:[email protected]",
    "folder": "'Examples/example1'"
    },
    { // Store all attachments from [email protected] to the SHARED Drive folder "Shared Drives/Lambda/Examples/example1"
    "parentFolderId": "FOLDER_ID_FOR_Examples_FOLDER", // This approach is with the ID of "Examples"
    "filter": "from:[email protected]",
    "folder": "'example1'" // Note: We omited the folder path "Examples" since it's the direct parent
    },
    { // Store all attachments from [email protected] OR from:[email protected]
    // to the folder "Examples/example3ab" while renaming all attachments to the pattern
    // defined in 'filenameTo' and archive the thread.
    // filenameTo supports the following printf style substitutions:
    // %s - The subject of the message/thread
    // %o - The original filename of the attachement
    "filter": "has:attachment (from:[email protected] OR from:[email protected])",
    "folder": "'Examples/example3ab'",
    "filenameTo": "'file-'yyyy-MM-dd-'%s.txt'",
    "archive": true
    },
    {
    // Store threads marked with label "PDF" in the folder "PDF Emails" als PDF document.
    //"filter": "label:PDF",
    "filter": "to:[email protected]",
    "saveThreadPDF": true,
    "folder": "PDF-Emails",
    "filenameTo": "'file-'yyyy-MM-dd-'%s.pdf'",
    },
    {
    // Store threads marked with label "PDF" in the folder "PDF Emails" als PDF document.
    // while renaming the PDFs to the pattern defined in 'filenameTo'.
    // filenameTo supports the following printf style substitutions:
    // %s - The subject of the message/thread
    // NOTE: .pdf will automatically be added to the file name
    //"filter": "label:PDF",
    "filter": "to:[email protected]",
    "saveThreadPDF": true,
    "folder": "PDF-Emails",
    "filenameTo": "'file-'yyyy-MM-dd-'%s'.pdf"
    },
    {
    // Store all attachments named "file.txt" from [email protected] to the
    // folder "Examples/example4" and rename the attachment to the pattern
    // defined in 'filenameTo' and archive the thread.
    // filenameTo supports the following printf style substitutions:
    // %s - The subject of the message/thread
    // %o - The original filename of the attachement
    // %d - A running counter from 1 for each match of this rule.
    "filter": "has:attachment from:[email protected]",
    "folder": "'Examples/example4'",
    "filenameFrom": "file.txt",
    "filenameTo": "'file-'yyyy-MM-dd-'%s.txt'"
    },
    {
    // Store all of the emails with the text "receipt" from [email protected]
    // into the folder "Examples/example5" and rename the filenames to be zoom-1.pdf, zoom-2.pdf...
    "filter": "receipt from:[email protected]",
    "folder": "'Examples/example5'",
    "filenameFrom": "*.pdf",
    "filenameTo": "'zoom-%d.pdf'"
    },
    {
    // Store threads marked with label "PDF" in the folder "PDF Emails" als PDF document and add "addPDFlabel" to the processed thread.
    //"filter": "label:PDF",
    "filter": "to:[email protected]",
    "ruleLabel": "addPDFlabel",
    "folder": "PDF-Emails",
    "filenameTo": "'file-'yyyy-MM-dd-'%s.pdf'",
    },
    ]
    };
    }
@piraveen
Copy link
Contributor

This PR should solve your request @boatmon0.
#73

Example Config:

      {
        // Store each INDIVIDUAL email as "PDF" instead of an entire thread, in the folder "PDF Emails"
        "filter": "from:[email protected]",
        "saveMessagePDF": true,
        "skipPDFHeader": true, // Skip Email Header
        "folder": "PDF Emails",
        "filenameTo": "'YOUR PREFIX-'yyyy-MM-dd'.pdf'"
      },

@ahochsteger
Copy link
Owner

Closing the issue since the issue has been fixed.
Note though, that GMail2GDrive is discontinued and has been superseded with the much improved Gmail Processor.
See the Getting Started Guide as well as the Reference Docs for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants