Hello
Documented feature.
path to is a Standard Additions feature.
If we call it in a tell application block, it issue an error.
With
tell application "Mail"
activate
path to documents folder
end tell
the log report is :
tell application "Mail"
activate
path to documents folder
--> error number -1708
«event ascrgdut»
--> error number -1708
path to documents folder
--> alias "Macintosh HD:Users:<userAccount>:Library:Containers:com.apple.mail:Data:Documents:"
end tell
You found a way to get rid of that.
An other one is to leave it where it was but encapsulate it in a tell current application block.
With
tell application "Mail"
activate
tell current application
path to documents folder
end tell
end tell
the log report is :
tell application "Mail"
activate
end tell
tell current application
path to documents folder
--> alias "Macintosh HD:Users:<userAccount>:Documents:"
end tell
Yvan KOENIG (VALLAURIS, France) mercredi 26 septembre 2012 10:14:58
G'day scripters
I've been following this with great interest. However, I've got a problem. Quite often our clients send emails with folders as attachments. The folders with their contents show as a single attachment, but can't be saved using the FILE command. Is there any answer to this please?
Regards
Santa
set ptd to path to desktop
set newFolderName to "2012-09-26 162222Z"
set newFolderPath to (ptd & newFolderName) as text
tell application "Finder"
if not (exists folder newFolderPath) then (make new folder at ptd with properties {name:newFolderName})
end tell
set newFolderPath to newFolderPath as alias
tell application "Mail"
activate
set tempmessage to message 1 of mailbox "* items to shift"
set selected mailboxes of message viewers to mailbox "* items to shift"
set theSelectedMessage to message 1 of mailbox "* items to shift"
repeat with eachAttachment in theSelectedMessage's mail attachments
try
save eachAttachment in file (newFolderPath & (name of eachAttachment) as rich text)
on error errmsg
try
save eachAttachment as (newFolderPath & (name of eachAttachment) as rich text) --< tried this for folder, but crashed
on error errmsg
display dialog errmsg
end try
end try
end repeat
end tell