User Tools

Site Tools


email_organization

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
email_organization [2025/03/22 20:49] – created lwattsiiemail_organization [2025/03/23 00:47] (current) lwattsii
Line 1: Line 1:
-<!DOCTYPE html> +====== Automated Gmail-to-PDF Archiving System ======
-<html> +
-<head> +
-  <title>Automated Gmail-to-PDF Archiving System</title> +
-  <style> +
-    body { font-family: Arial, sans-serif; background: #fefefe; padding: 40px; color: #333; line-height: 1.6; } +
-    h1, h2 { color: #2a2a2a; } +
-    code { background: #f4f4f4; padding: 2px 6px; border-radius: 3px; font-size: 90%; } +
-    ul { margin-top: 0; } +
-  </style> +
-</head> +
-<body> +
-  <h1>Automated Gmail-to-PDF Archiving System</h1>+
  
-  <h2>Purpose</h2> +[[Archive Update|Archive Update]]
-  <p>This system automatically searches Gmail for emails sent <strong>to or from specific contacts or domains</strong>, converts them into PDFs, and stores them in named folders in Google Drive. It's used to keep a searchable, organized, and timestamped record of key communications for future reference, especially across insurance and claim-related projects.</p>+
  
-  <h2>What It Does</h2> +===== Purpose ===== 
-  <ul> +This system automatically searches Gmail for emails sent **to or from specific contacts or domains**, converts them into PDFs, and stores them in named folders in Google Drive. It's used to keep a searchableorganized, and timestamped record of key communications for future reference, especially across insurance and claim-related projects.
-    <li>Searches Gmail for all emails <strong>to or from</strong>specific sender or domain.</li> +
-    <li>Converts each email into a timestamped <code>.pdf</code> file using Google Apps Script.</li> +
-    <li>Stores the PDFs in organized folders within Google Drive, named after the contact or domain.</li> +
-    <li>Filenames are standardized: <code>YYYY-MM-DD - TO/FROM email@domain.com - Subject.pdf</code></li> +
-  </ul>+
  
-  <h2>How It Works</h2> +===== What It Does ===== 
-  <ol> +  * Searches Gmail for all emails **to or from** a specific sender or domain. 
-    <li>Create new <a href="https://script.google.com" target="_blank">Google Apps Script</a> project.</li> +  * Converts each email into timestamped **.pdf** file using Google Apps Script. 
-    <li>Paste the provided script for the desired sender/domain (see examples below).</li> +  * Stores the PDFs in organized folders within Google Drive, named after the contact or domain. 
-    <li>Run the script and authorize permissions when prompted.</li> +  * Filenames follow this format: ''YYYY-MM-DD - TO/FROM email@domain.com Subject.pdf''
-    <li>The script will auto-create a Drive folder (if not existing) and populate it with generated PDFs.</li> +
-  </ol>+
  
-  <h2>Script Template</h2> +===== How It Works ===== 
-  <p>Replace <code>@example.com</code> or <code>user@example.com</code> with your target domain or address:</p>+  - Create a new [[https://script.google.com|Google Apps Script]] project. 
 +  - Paste the provided script for the desired sender/domain (see below). 
 +  - Run the script and authorize permissions. 
 +  - The script auto-creates a Drive folder (if not existing) and fills it with PDFs.
  
-  <pre><code>function archiveAllEmailsWithDomain() {+===== Script Template ===== 
 +Replace ''@example.com'' or ''user@example.com'' with your target domain or address: 
 + 
 +<code javascript> 
 +function archiveAllEmailsWithDomain() {
   var domain = "@example.com";   var domain = "@example.com";
   var threads = GmailApp.search("from:" + domain + " OR to:" + domain);   var threads = GmailApp.search("from:" + domain + " OR to:" + domain);
Line 62: Line 49:
     }     }
   }   }
-}</code></pre>+} 
 +</code> 
 + 
 +===== Configured Examples ===== 
 +  * **Shari Bradix (specific address):** ''Shari.Bradix@cna.com'' 
 +  * **All CNA contacts:** ''@cna.com'' 
 +  * **All J.S. Held engineers:** ''@jsheld.com'' 
 +  * **Bockmon Insurance:** ''@bockmoninsurance.com'' 
 + 
 +===== Next Steps (Optional) ===== 
 +  * Add automatic scheduling to run these scripts daily/weekly. 
 +  * Enhance script to export attachments or summarize content with AI. 
 +  * Back up Drive folders to external storage/cloud systems. 
 + 
 +---- 
 +''This system is designed for accuracy, automation, and fast retrieval of critical email communication records.'' 
 + 
 +====== Email Organization Overview ====== 
 + 
 +This page documents how our Gmail-to-PDF email archiving system is structured for project organization, historical tracking, and AI analysis. Each category corresponds to a specific contact, domain, or role, with emails exported and stored in clearly named Google Drive folders. 
 + 
 +===== Folder Structure and Categories ===== 
 + 
 +  * **Gmail PDFs - Shari Bradix (All)** → All emails to/from Shari.Bradix@cna.com 
 +  * **Gmail PDFs - CNA (All Emails)** → All emails to/from @cna.com 
 +  * **Gmail PDFs - CNA Other than Shari** → All CNA emails excluding Shari.Bradix@cna.com 
 +  * **Gmail PDFs - J.S. Held (All Emails)** → All emails to/from @jsheld.com 
 +  * **Gmail PDFs - Bockmon Insurance (All Emails)** → All emails to/from @bockmoninsurance.com 
 +  * **Gmail PDFs - Marshall Texas (All Emails)** → All emails to/from @marshalltexas.net 
 +  * **Gmail PDFs - Eric Powell (Marshall Texas)** → All emails to/from Powell.eric@marshalltexas.net 
 + 
 + 
 +===== Notes on Script Execution ===== 
 + 
 +Scripts are designed to run one-time only (manually), and generate a PDF of each email retrieved by the Gmail query. All scripts follow the same structure: loop through threads → extract each message → convert to PDF → save in Drive folder. 
 + 
 +Each script is mapped to a unique folder name for safe targeting and easy retrieval. 
 + 
 + 
 +===== Special Case: Eric Powell Email Filtering ===== 
 + 
 +Eric Powell’s original archive script was missing some emails. This was due to Gmail’s `.getTo()` and `.getFrom()` fields sometimes being blank or incomplete in: 
 + 
 +  * Sent mail 
 +  * BCC’d messages 
 +  * Threaded replies where Powell was in earlier parts of the conversation 
 + 
 +Gmail correctly returned the threads, but the script was skipping emails inside those threads based on this check: 
 +```javascript 
 +if (!(sender.includes(email) || recipient.includes(email))) { 
 +  continue; 
 +
 +``` 
 + 
 +**Fix:** 
 +We replaced this logic with a cleaner, dual-check method: 
 +```javascript 
 +var isFrom = sender.includes(email.toLowerCase()); 
 +var isTo = recipient.includes(email.toLowerCase()); 
 +if (!isFrom && !isTo) continue; 
 +``` 
 +This ensures that every message **directly involving Powell** is captured — no more skipped BCCs or sent replies. 
 + 
 +Other scripts (like domain-based searches for `@cna.com`) are not affected because they cast a wider net and don’t rely on a single recipient match. 
 + 
 + 
 +===== Status ===== 
 + 
 +All seven archiving scripts are now finalized and verified: 
 +  * 🟢 Folder names confirmed 
 +  * 🟢 Gmail queries validated 
 +  * 🟢 Powell fix implemented only where needed 
 +  * 🟢 Manual execution completed with no errors
  
-  <h2>Configured Examples</h2> +We are ready to move to the summarization/AI review phase.
-  <ul> +
-    <li><strong>Shari Bradix (specific address):</strong> <code>Shari.Bradix@cna.com</code></li> +
-    <li><strong>All CNA contacts:</strong> <code>@cna.com</code></li> +
-    <li><strong>All J.S. Held engineers:</strong> <code>@jsheld.com</code></li> +
-    <li><strong>Bockmon Insurance:</strong> <code>@bockmoninsurance.com</code></li> +
-  </ul>+
  
-  <h2>Next Steps (Optional)</h2> 
-  <ul> 
-    <li>Add automatic scheduling to run these scripts daily/weekly.</li> 
-    <li>Enhance script to export attachments or summarize content with AI.</li> 
-    <li>Back up Drive folders to external storage/cloud systems.</li> 
-  </ul> 
-</body> 
-</html> 
  
email_organization.1742676543.txt.gz · Last modified: 2025/03/22 20:49 by lwattsii