# Apple Mail Integration *Optional. macOS + Apple Mail only.* This integration logs the email you have selected in Apple Mail straight into your vault as a fully-formatted Email activity note — including downloading its attachments — with a single keystroke. The complete script is on the [[Mail Logging Script]] page. ## What it does Select a message in Apple Mail, trigger the script, and it: 1. Reads the message's subject, sender, date, body, and a deep link back to it. 2. Creates `Activities/Emails/YYYY-MM-DD Email - <subject>.md` with the standard Email frontmatter and body. 3. **Downloads every attachment** into `Activities/Emails/Attachments/<Year>/<Month>/`, skipping tiny inline images (signatures, logos) under 10 KB. 4. Lists each attachment as a wiki-link in the note's `attachments:` frontmatter and embeds it under an `## Attachments` heading. 5. Opens the new note in Obsidian. You then add the `people:`, `projects:` (etc.) links and a summary. The email instantly appears on every linked dimension's timeline. ## Prerequisites - macOS with Apple Mail set up with your account. - An Obsidian vault synced via iCloud (the script's paths assume `~/Library/Mobile Documents/iCloud~md~obsidian/Documents/`). Adjust if yours lives elsewhere. ## Setup ### 1. Personalize the script Open the [[Mail Logging Script]] page, copy the script, and edit the placeholders at the top: ```applescript property vaultRoot : "/Users/YOUR_USERNAME/Library/Mobile Documents/iCloud~md~obsidian/Documents/YOUR_VAULT" ``` Set `YOUR_USERNAME` and `YOUR_VAULT`. Set `isAcademic` to `false` if your vault has no classes/assignments (it controls whether those frontmatter fields are added). ### 2. Create a Shortcut to run it The easiest way to bind the script to a keystroke is the macOS **Shortcuts** app: 1. Open **Shortcuts** → **+** to create a new shortcut. Name it e.g. "Log Mail to Obsidian". 2. Add the action **Run AppleScript**. 3. Paste the entire contents of the script into that action. 4. Run it once from the Shortcuts editor (with a message selected in Mail) to approve the automation permissions macOS prompts for. 5. In the shortcut's settings, assign a **keyboard shortcut**, or pin it to the menu bar. > [!important] The Shortcut stores its own copy of the script > The "Run AppleScript" action keeps the script text **inline**. The `.applescript` file is just your source of truth — whenever you edit it, paste the new version back into the Shortcut for changes to take effect. ### 3. (If needed) the iCloud write workaround The script already handles a macOS quirk: the Shortcuts sandbox can't write directly to iCloud Drive, so the script writes to `/tmp` first and then uses a shell `mv` to move the file into the vault. You don't need to do anything — just know that's why the code shells out. ## Make selecting one message reliable Apple Mail's **conversation view** groups a thread into one row, which can make "the selected message" ambiguous. For one-message-at-a-time logging, turn it off: **Mail → View → Organize by Conversation** (uncheck). Every message becomes its own selectable row. There is no setting to *permanently* keep conversations expanded, so disabling grouping is the cleaner fix; alternatively assign a hotkey to **View → Expand All Conversations**. ## How routing to multiple vaults works (advanced) The version here logs to one vault. If you keep several vaults (e.g. separate work and personal vaults), you can extend the script to **route by the account a message belongs to** — reading the message's account email/name and choosing a different `vaultRoot` based on it (e.g. a work-domain address → your work vault, everything else → a personal vault). The structure is: gather the account info inside the `tell application "Mail"` block, then pick `vaultRoot`/`vaultName` before writing. Keep one Shortcut; the script decides where each message lands. ## Troubleshooting - **Nothing happens / "no message selected":** click a message in Mail's list first, then trigger the shortcut. - **Attachments not downloading:** the account must be online so Mail can fetch them; the script triggers a download if they aren't cached. - **Permission errors:** re-run the shortcut from the Shortcuts editor once to re-approve Automation permissions for Mail. Next: [[09 Todoist Integration|Todoist Two-Way Sync]].