Smart Mail use

Hi

(My company does not support Entourage so I am stuck with Mail)

If I recieve an email from someone who is not assigend to a Mail rule, can I set a script to create a new folder in a specific place, name it according to the persons name, and automatically create a rule that will filter their email to the new folder for all future emails?

phew! if there is it would save me hours of silly rule setting!

Thanks

:confused:

Yes, you could do that. How far have you gotten with your script?

As it happens, Michelle Steiner posted a similar beast for outgoing messages in the alt.comp.lang.applescript news group on Monday. Hereโ€™s an adaptation for use on a selected, received message, which you could further adapt to your own requirements:

-- adapted from Michelle Steiner
tell application "Mail"
	-- Get the sender's address.
	set foo to the selection
	set foo to item 1 of foo
	set address_ to sender of foo
	
	-- Parse the address for a suitable folder and rule name.
	set astid to AppleScript's text item delimiters
	if address_ contains "<" then
		set AppleScript's text item delimiters to " <"
	else
		set AppleScript's text item delimiters to "@"
	end if
	set folder_name to text item 1 of address_
	set AppleScript's text item delimiters to astid
	
	-- Make a new mailbox.
	if not (mailbox folder_name exists) then
		make new mailbox at end of mailboxes with properties {name:folder_name}
	end if
	
	-- Make a new rule and enable it.
	if not (rule folder_name exists) then
		set new_rule to (make new rule at after rule 1 with properties {name:folder_name, move message:mailbox folder_name, should move message:true, stop evaluating rules:true})
		tell new_rule
			make new rule condition with properties {expression:address_, rule type:from header, qualifier:does contain value}
			set enabled to true
		end tell
	end if
end tell