Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Another script to file Mail.app messages by sender Apps
After seeing this hint and this hint, both regarding filing of received Mail.app messages, neither did exactly what I liked ... so I started with the second one and revised it to meet my needs. This version now supports:
  • Optional prompt
  • Optional subfolder
  • Optional set mailbox to name from Address Book
  • Multiple email messages selected
  • Support multiple accounts, saves to mailbox on that IMAP account for example
  • Automatically create the new mailbox if not prompting user
  • Hard coded email aliases (replaced with Address Book lookup)
I didn't want to be prompted each time, so I turned if off but left the code in. I don't use subfolders, so I turned that off (NOTE: I haven't tested using them at all, so it might be broken). The first hint used a shareware library (I think) to look up the full name of the sender from the Address Book. I just call Address Book directly and look it up. This adds a short pause to the script, depending on how many entries are in your Address Book.

This is my first time playing AppleScript, so there might be some stupid things in there but it seems to work for me and does what I want. I haven't done a very good job of commenting how to use it and exactly what it does. Between my five-week old daughter and behind-schedule projects, I am not sure if/when I will get that part done.

[robg adds: Due to the length of the script, I've put the source on macosxhints -- file_mail.txt. I haven't tested this one...]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[3,710 views]  

Another script to file Mail.app messages by sender | 10 comments | Create New Account
Click here to return to the 'Another script to file Mail.app messages by sender' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another script to file Mail.app messages by sender
Authored by: pfschill on Aug 24, '04 07:26:25PM

After posting this I made additional changes to the script to make it work a little more like my good ol' pine. The new script opens a dialog w/ the mailbox prefilled (if promptUser is 1). This allows you to easily change the mailbox and hit enter. Correct by default? Just hit enter. You can turn off the prompt if you want it to just save. I have an alias to each so if I want to move a bunch of messages I don't have to keep hitting enter.

I also have a new option to prepend the company from Address Book so all clients from the same company group together.

Here is the new source



[ Reply to This | # ]
Another script to file Mail.app messages by sender
Authored by: gadg on Aug 25, '04 08:32:24AM
I wrote the script in the first hint you are referring to. It does not use external shareware or libraries to figure out the name in the Address Book but does it just like your script does. The scripting library it does use is used for displaying progress.

Seems our scripts do just about the same, except you use different IMAP accounts and offer the creation of new mailboxes. I like the latter, I have no need for the first.

After publishing the original script, I copied/altered it to also sort outgoing messages. I periodically invoke both scripts to sort messages in my inbox and outbox. The last couple of weeks I've been thinking about building a new version of the script to combine the two tasks, which is more modular, allows for more custom settings for the user and has a better user interface. Time constraints (10 month old 'daughter'), lack of AppleScript knowledge and busy schedule have kept me from diving into it too much. I also see a possibility of continued development into an Automator Workflow.

---
the difference between men and boys, is the price of their toys

[ Reply to This | # ]

Another script to file Mail.app messages by sender
Authored by: lanej0 on Aug 25, '04 03:22:31PM

I just made one minor modification to the script posted. At the end, I added a:

tell application "Address Book"
quit
end tell

This script launches Address Book if you've got checking enabled. No reason to leave it open after the script has finished executing.

Does it bug anyone else that iSync doesn't automatically quit after a Palm Hotsync operation?



[ Reply to This | # ]
Another script to file Mail.app messages by sender
Authored by: gadg on Aug 25, '04 04:44:27PM

What if I had Address Book already running, does it still quit it? I don't know if it's possible to check that and set a status variable somewhere for reference before quitting.

---
the difference between men and boys, is the price of their toys



[ Reply to This | # ]
Another script to file Mail.app messages by sender
Authored by: lanej0 on Aug 25, '04 06:07:35PM
Yeah, I'm sloppy. I rarely ever have address book running -- I use Launchbar for contacts. You can check to see if Address Book is running already, and if it is, leave it running. This little snip should do the trick for you:

tell application "System Events"
	if ((application processes whose (name is equal to "Address Book")) count) is greater than 0 then
		set abRun to "yes"
	else
		set abRun to "no"
	end if
end tell

if abRun is "no" then
     tell application "Address Book" to quit
end if


[ Reply to This | # ]
Another script to file Mail.app messages by sender
Authored by: pfschill on Aug 25, '04 09:53:36PM

Good suggestions. I added the option to close AB as an option to my script. I had a different way to lookup if AB was running but it looks like you are a more experienced AppleScripter than I am so I used your version.

I had been just staring AB on login to speed up the lookups.



[ Reply to This | # ]
Error creating mailbox / moving message
Authored by: NewEd on Aug 25, '04 10:50:37PM

This is a great feature for such a script.

But I cannnot use it.

Everytime I have test it, I get the error message that the mailbox cannot be created. (The dialogue coded into the script returns: "Error creating the mailbox: "...)

Even if I choose an existing mailbox, the same error dialogue appears.

Any advice for what might be wrong? I very much want to be able to use this.



[ Reply to This | # ]
Fix for POP accounts
Authored by: NewEd on Aug 26, '04 01:03:57AM

I have been in email contact with Paul (the original submitter of this hint) about problems I was having with getting it to run with my POP accounts. (The above comment.)
He pointed out that the key is removing the reference to "theAccount" (an IMAP feature).

The three lines that therefore need to be changed are:

set mboxName to mailbox named theMailbox of account theAccountName
to
set mboxName to mailbox named theMailbox

&

tell theAccount to make new mailbox with properties {name:theMailbox}
to
make new mailbox with properties {name:theMailbox}

&

move the theMsg to mailbox theMailbox of account theAccountName
to
move the theMsg to mailbox theMailbox


I hope this helps anyone else using POP accounts!

Thanks.




[ Reply to This | # ]
Fix for POP accounts
Authored by: pfschill on Aug 26, '04 11:20:39AM

I put up a modified version that now has an option "storeLocally" Just set it to 1 if you use POP and it will store the messages "On My Mac" rather than remotely on the IMAP account.



[ Reply to This | # ]
Another script to file Mail.app messages by sender
Authored by: nbirnbaum on Sep 02, '05 09:31:05PM

This doesn't work for me. When I run the script from Mail.app, nothing happens at all. Any suggestions?



[ Reply to This | # ]