Mail in Postfach 2.1

Das Skript via FastScripts erleichtert das Bewegen von Emails in Unterordner. Diese Version hat einen kleinen Bugfix, so dass auch mehrere Emails in einem Rutsch korrekt bewegt werden.

-- MoveMailTo
--  Created by Hubi on 16.06.2009
--Änderung vom 07.12.2009
--     ->Unterordner können nu auch als Ziel genutzt werden
--     ->POP Accounts bzw. lokale Ordner können nun auch angesprochen werden.
--  Copyright 2009 hubionmac.com. All rights reserved. ;-)
-- 20.06.2013 Bugfix... so it works with more than one selected mail using Mac OS 10.7
tell application "Mail"
  
  set theSelection to selection
  if theSelection ≠ {} then
    try
      set ac_name to (name of account of mailbox of (item 1 of theSelection))
      set ac_typ to account type of account of mailbox of (item 1 of theSelection)
    on error
      --wenn eine Nachricht in einem lokalen Postfach ausgewählt wurde kann das nur schief gehen, also:
      set ac_name to ""
      set ac_typ to pop
    end try
    set t_mail to {}
    if ac_typ = imap then
      repeat with i from 1 to (count of every mailbox of account ac_name)
        --set t_mail to t_mail & ((i & " " & name of mailbox i of account ac_name) as text)
        set t_mail to t_mail & ((name of mailbox i of account ac_name & " (" & i & ")") as rich text)
      end repeat
    else if ac_typ = pop then
      repeat with i from 1 to (count of every mailbox)
        --set t_mail to t_mail & ((i & " " & name of mailbox i of account ac_name) as text)
        set t_mail to t_mail & ((name of mailbox i & " (" & i & ")") as rich text)
      end repeat
    end if
    
    
    set my_mailboxes to {"•••NEW•••"} & t_mail
    set theaction to choose from list my_mailboxes default items {item 1 of my_mailboxes}
    if theaction as rich text ≠ "false" then
      if theaction as rich text = (item 1 of my_mailboxes) as rich text then
        set new_mailboxname to text returned of (display dialog "New Mailbox" default answer "---New Mailbox ---")
        if new_mailboxname as rich text ≠ "false" then
          if ac_typ = imap then
            tell account ac_name to set desti_box to (make new mailbox with properties {name:new_mailboxname})
          else if ac_typ = pop then
            make new mailbox with properties {name:new_mailboxname}
            set desti_box to new_mailboxname
          end if
        end if
      else
        --set desti_box to mailbox ((first word of (theaction as text)) as integer) of account ac_name
        if ac_typ = imap then
          set desti_box to mailbox ((last word of (theaction as rich text)) as integer) of account ac_name
        else if ac_typ = pop then
          set desti_box to mailbox ((last word of (theaction as rich text)) as integer)
        end if
      end if
      repeat with themessage in theSelection
        
        move themessage to desti_box
      end repeat
    end if
  else
    display dialog "Nix ausgewählt zum verschieben" giving up after 1
  end if
end tell
									

2 thoughts on “Mail in Postfach 2.1

  1. Moss the TeXie says:

    Wozu brauche ich das? Mails in Unterordner sortieren kann Mail eigentlich schon ganz gut.

  2. Hubi says:

    Hallo Moss,

    ich habe keine Ahnung was Du brauchst… ;-P
    Ich benutzte das Skript, um via FastScripts Mails über Tastatureingabe zu sortieren.

    Gruß Hubi

Leave a Reply