0

At the company I work with, we use [client-domain.com] prefixes before the actual subject line of emails as kind of a rough tagging system.

Is there any way that one could automate this so when I start writing a new email to [email protected], the subject will be pre-populated by [foobar.com]?

3
  • 1
    That's not too easy (like, triggering automatically). I'd say it's pretty easy though to set up an Automator action that allows you to pre-populate a "new message" field. Would that be working for you?
    – slhck
    Commented Feb 9, 2012 at 8:17
  • What happens when the client gets rid of this junk when replying to that email?
    – Daniel Beck
    Commented Feb 9, 2012 at 8:28
  • 1
    What I meant to say is, wouldn't it be better if you just created Smart Folders, one per client, and used the To/From email address as criterion?
    – Daniel Beck
    Commented Feb 9, 2012 at 13:04

1 Answer 1

2

A quick and dirty AppleScript attempt to achieve what you want, but it certainly can be improved, i.e. being bound to Automator actions, based on selection from selected items in your address book.

To use this, open "AppleScript Editor" (it's in /Applications/Utilities/, or use Spotlight), paste the following as the text body and click "run". If it's OK, you can save the script and later run it by clicking on it.

   set recipientList to display dialog "Enter the email address:" default answer ""       
   tell application "Mail"
        set composeMessage to make new outgoing message at beginning with properties {visible:true}

        tell composeMessage
            set recipientList to (text returned of recipientList)
            make new to recipient at end of to recipients with properties {address:recipientList}
            set AppleScript's text item delimiters to "@"
            set domain to text item 2 of recipientList
            set subject to "[" & domain & "]"
        end tell
    end tell

Of course, this can be improved upon.

Also, you should know, as pointed out by Daniel Beck that the recipient is free to remove that field; it's best to rely on hidden mail headers. But given you already have the domain, this info is safely stored in the email recipient.

2
  • I'd move the display dialog to the first line. That way, the user can still cancel without mail being focused, Spaces being switched, and the new mail window created.
    – Daniel Beck
    Commented Feb 9, 2012 at 12:19
  • @DanielBeck: Good point. Edited.
    – Karolos
    Commented Feb 9, 2012 at 12:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .