How to ask for a mail folder in applescript? I apologise in advance since this will be a long question. I hope that somebody with applescript knowledge can help me. I am transferring whole of my Windows machines to Apple and I am stuck with one last little annoying thing. Within Outlook I had a macro running that asked me where to file a mail after sending it. I am used to file projects in separate folders and have the incoming and outgoing mail there together. Most of the items I send BTW go into the trash folder. In other words, my sent items folders is always empty.

For reference purposes I attach the original macro below.

I tried this through rules but now understand that Mail does not support rules on sent items. Then I ended up with the automator and applescript. I have found some examples on the internet that move selected mails to a specific (preset) folder. That is however not what I need, I need the script to ask me every time what folder to use.

The next thing I cannot found is some kind of automatic trigger when I send a mail. It would for instance be possible through an option "when a mail gets stored in sent mail". Or something similar. The next best thing is just a key board shortcut that starts the macro although this is pretty close to doing it manually by just moving sent mail to a specific folder.

Anyway, I hope my question is clear and some intelligent applescript guru amongst you has a way to deal with this.

Thanks in advance!

Arnoud



COPY OF MY ORIGINAL VBA CODE USED ON THE WINDOWS OUTLOOK SETUP

Dim objFolder As MAPIFolder

 ' Variable declaration
 Dim objNS As NameSpace
 Dim colKeywords As New Collection
 Dim vntRecipients As Variant
 Dim bolExternalEmail As Boolean

 ' Set variables
 Set objNS = Application.GetNamespace("MAPI")

 ' Set up list of keywords that you use when attaching files
 colKeywords.Add "attachement"
 colKeywords.Add "Attachement"
 colKeywords.Add "attached"
 colKeywords.Add "Attached"

 ' Check for attechment keywords and check for number of attachments
 If checkForKeywords(colKeywords, Item.Body) And (Item.Attachments.Count = 0) Then

 ' If attachments should be in email ask for continue
 If MsgBox("Attachement missing. Send e-mail anyway?", vbYesNo) = vbNo Then
 Cancel = True
 Exit Sub
 End If

 End If

 ' Check for subject
 If Item.Subject = "" Then
 MsgBox "Please specify a subject"
 Cancel = True
 Exit Sub
 End If

 ' Only enable actions for emails
 If Item.Class = olMail Then

 ' Get folder to save email
 Set objFolder = objNS.PickFolder

 ' Check if folder has been specified
 If TypeName(objFolder) &lt;&gt; "Nothing" Then

 ' If folder has been specified move email
 Set Item.SaveSentMessageFolder = objFolder
 Else
 ' Otherwise do not send email and get back to email
 Cancel = True
 End If

 End If

send_message:
 ' Unset everything
 Set objFolder = Nothing
 Set objNS = Nothing

End Sub
While I don't know if AppleScript can do what you want, there is an Apple Mail plug-in called Mail Hub that will do what you want as well as add additional functionality. I'm a satisfied customer.