lohaev.blogg.se

Automatically email new files in a folder
Automatically email new files in a folder










  1. AUTOMATICALLY EMAIL NEW FILES IN A FOLDER PDF
  2. AUTOMATICALLY EMAIL NEW FILES IN A FOLDER CODE

This is a known bug that has been reported for years over multiple OS X and MacOS versions. I should have been a bit clearer: the issue is related to obtaining and saving attachments to mail message via AppleScript. I am not convinced that the script quality is the issue. I hope this workflow is for the followup.

  • Hazel takes over and (if the file has been on the desktop for at least 1 hour) moves all the files into the correct subfolder of my MailArchive folder using the tag assigned based on the mail account.
  • AUTOMATICALLY EMAIL NEW FILES IN A FOLDER PDF

    I also take the mail pdf as “email”, the raw file as “rawemail” and each attachment as “attachment.” If there are attachments I also add a “hasattachment” tag to the mail pdf. Based on the account it came from I assign a tag to each file.

  • Use the account name to assign tags to the files thus created.
  • Rename the mail pdf using the prefix as above.
  • Use KM user interface scripting to have Mail.app save the email itself to a PDF on the desktop.
  • Return from the script the filename prefix, the raw file name, and the name of each attachment file. Rename the file containing the raw file using the prefix with _raw appended (I keep that because it is easy to search via grep).
  • Run the python script which takes the raw file and saves the attachments on the desktop, using the filename prefix above as computed.
  • Otherwise, save the account name in a KM variable.

    automatically email new files in a folder

    Check for the error codes and display error messages and quit.

    AUTOMATICALLY EMAIL NEW FILES IN A FOLDER CODE

    Return from the script the accountName found above (or an error code if there is a problem, like more than one message selected). Use AppleScript to find the current selected message (make sure there is only one) and write the entire message content to a file on the Desktop.I tie the entire thing together in a Keyboard Maestro macro (that I will likely post on the MPU forum once I have a bit of time. Where theMessage is the selected message in Mail.app. Set accountName to the name of the account of the mailbox of theMessage To be able to sort the email messages, from AppleScript I use: I name the files using the format YYYY-MMDD_MD5_filename where YYYY-MMDD is the date the mail was sent, MD5 is the MD5 hash of the entire mail content (that makes sure that all saved files are unique to the email message, and filename is the filename for the attachment. My approach is to save the entire email message (the raw content) to a file and run a python script that pulls out the attachments and saves them to disk. This problem has existed for years and never been fixed by Apple, and for that reason my workflow for saving emails is NOT based on using AppleScript to save the attachments. I have found that Mail.app’s AppleScript support is highly flakey, especially when it comes to saving attachments reliably.












    Automatically email new files in a folder