Encrypt file with password and attach file to KM Mail action

How could I do the following:

  1. Encrypt the most recently added file to ‘Downloads’ using a password named ‘2qau4’
  2. Then attach that File to KM Mail action

Please see my post here. You have to specify the program you are using to encrypt the file. Otherwise it’s almost impossible to help you to build a macro.

See the hints given here. You have said “I know how to attach files in KM Mail”. So, what is the specific problem?

Just an idea: Build a macro along the lines you think it should work out. Post it here for review.

Hi Tom,
Thank you for your response, I would want to ZIP the file with a particular password for cross platform use.

Not sure how to upload the image of the macro but I have put it here instead.

KM - Grab LOA file to Downloads, rename file, encrypt with password and attach to Mail .kmmacros (6.9 KB)

any advise?

Hi Ali,

I’m in vacations right now, without any Mac (fortunately ;)), so I cannot open your macro.

I hope someone else will have a look at your macro.

For the moment so much:

Be careful with ZIP encryption. The original ZIP encryption is/was known to be very easily crackable. I don’t know if this is fixed in recent versions. Since I still don’t know which program you are using to create the archive you have to research if the encryption used by the particular program is secure.

As already mentioned, I recommend the 7zip program. As far as I know its encryption is secure, and you can also create ZIP archives with 7zip. (For maximum compatibility don’t use the deflate64 option.)

Search the forum for something like “upload macro screenshot” or have a look at the KM Wiki (the article isn’t hard to find).


Unfortunately I’m back from vacations :frowning:

I can’t help you much with your Daylite AppleScripts, since I don’t know that app nor its AS dictionary. The scripts seem a bit strange to me, but I guess you have run them in Script Editor before pasting them to KM.

However I can help you with the encryption part of the macro.

This macro will create an encrypted Zip archive from a given file path (stored in the first variable):

[demo] Create Encrypted Zip with p7zip.kmmacros (2.8 KB)

You see two Shell Script actions, one disabled and the other one enabled. The enabled one uses strong AES256 encryption, the disabled one uses the weak ZipCrypto encryption.

Of course, the AES encryption is preferable, but you have to find out if your recipients’ Zip unarchivers are compatible with it. For example, on the Mac the AES-encrypted archives cannot be opened with the macOS standard Archive Utility.app (but they open fine with The Unarchiver). I don’t know the situation on Windows or Linux.

The weaker ZipCrypto encryption should be widely compatible.

The reference for the available 7zip switches is here.


The macro is using a password stored in a variable, that means the password gets written to disk in clear text. This shouldn’t be a problem, since you probably have the clear-text attachments also on disk. But do not use the macro with a password that you are also using for other, more important stuff (for example your LastPass/1Password master password)!

For the macro to work you need to have…

Hope this helps!