• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How can I open attachment in Mail ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I open attachment in Mail ?


  • Subject: Re: How can I open attachment in Mail ?
  • From: kai <email@hidden>
  • Date: Mon, 23 Oct 2006 02:02:33 +0100


On 19 Oct 2006, at 18:00, Victor Frenklakh wrote:

I need to open attached file coming to inbox. Do you know any build in method to do it?

It's probably not such a great idea to open attachments indiscriminately, Victor - so you may want to consider applying some rules that offer a degree of security. (You could, for example, limit automatic opening to only those attachments received from trusted sources.)


When you open an attachment by clicking it in a message, Mail temporarily saves it as a separate file to your Mail downloads folder (the default location of which is /Users/user name/Library/Mail Downloads/). One way of achieving your aim might therefore be to simulate that process using AppleScript.

The script below is intended to be triggered by a Mail rule, so (in case you're unsure) you'll need to:

------------------
• save the script (File Format: Script) to a suitable location
• add a new rule in Mail/Preferences.../Rules
• specify the relevant conditions for the rule
• from the options under "Perform the following actions:", select "Run AppleScript"
• click the "Choose..." button
• choose the script you just saved
------------------


Here's the script:

------------------

on download_path()
set f to (do shell script "defaults read com.apple.mail MailDownloadsPath") & "/"
if f does not start with "~" then return f
set h to POSIX path of (path to home folder)
if (count f) < 3 then return h
h & f's text 3 thru -1
end download_path


on unique_name(n, l)
	if n is in l then
		if "." is in n then
			set d to text item delimiters
			set text item delimiters to "."
			set e to "." & n's text item -1
			set n to n's text 1 thru text item -2
			set text item delimiters to d
		else
			set e to ""
		end if
		set v to -1
		repeat while n & v & e is in l
			set v to v - 1
		end repeat
		set l's end to n & v & e
	else
		set l's end to n
	end if
end unique_name

using terms from application "Mail"
	on perform mail action with messages msgs
		set p to POSIX file download_path() as Unicode text
		set l to list folder p without invisibles
		repeat with m in msgs
			repeat with a in m's mail attachments
				set f to p & unique_name(a's name, l)
				save a in f
				tell application "Finder" to open f
			end repeat
		end repeat
	end perform mail action with messages
end using terms from

------------------

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: How can I open attachment in Mail ?
      • From: Victor Frenklakh <email@hidden>
    • Re: How can I open attachment in Mail ?
      • From: Philip Aker <email@hidden>
References: 
 >How can I open attachment in Mail ? (From: Victor Frenklakh <email@hidden>)

  • Prev by Date: Re: mailbox list visible
  • Next by Date: If I can defend myself... (was 'Re: FileMaker (Pro Advanced 8) bug?')
  • Previous by thread: How can I open attachment in Mail ?
  • Next by thread: Re: How can I open attachment in Mail ?
  • Index(es):
    • Date
    • Thread