• 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: Mail: save attachment fails in Mountain Lion 10.8.2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail: save attachment fails in Mountain Lion 10.8.2


  • Subject: Re: Mail: save attachment fails in Mountain Lion 10.8.2
  • From: Brian Christmas <email@hidden>
  • Date: Thu, 27 Sep 2012 09:56:47 +1000


On 26/09/2012, at 11:16 PM, koenig.yvan <email@hidden> wrote:


Le 26/09/2012 à 11:08, Brian Christmas <email@hidden> a écrit :


On 26/09/2012, at 6:15 PM, koenig.yvan <email@hidden> wrote:

…

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


Try to replace :

save eachAttachment in file (newFolderPath & (name of eachAttachment) as rich text)
by

save eachAttachment in file (newFolderPath & ":" & (name of eachAttachment) as rich text)

Yvan KOENIG (VALLAURIS, France) mercredi 26 septembre 2012 15:16:20

G'day Yvan.

Thanks, but that doesn't work. The colon is added to the name with the line...

set newFolderPath to newFolderPath as alias

I've tried to use the GUI, and it works, but I needed to make it bullet proof, hence all the calls to activate 'Mail' during saving. FWIW I've had a long standing bug report since Lion, that saving mail as rtfd's with attachments does not save folders in the rtfd. I suspect the necessity to add the 'file' command has also stopped folders being saved.

Regards

Santa

global newFolderName
global ptd
global posixPath

on run
set ptd to path to desktop
set posixPath to POSIX path of ptd


tell application "Mail"
activate
if (count of windows) > 1 or (count of windows) = 0 then
quit
delay 2
activate
end if


set the visible of every window to true
set selected mailboxes of message viewers to mailbox "* items to shift"
set tempmessages to messages of mailbox "* items to shift"
if (count of tempmessages) > 0 then
repeat with MessageCount from 1 to count of tempmessages
my CreateFolder()
activate
set the selected messages of message viewers to message MessageCount of mailbox "* items to shift"
my saveAttachments()
delay 1
end repeat
end if
end tell
end run

on saveAttachments()
tell application "Mail" to activate
tell application "System Events" to tell process "Mail"
if enabled of menu item "Save Attachments…" of menu 1 of menu bar item "File" of menu bar 1 is true then
--say "menu exists"
click menu item "Save Attachments…" of menu 1 of menu bar item "File" of menu bar 1
repeat until exists pop up button 1 of group 1 of sheet 1 of window 1
tell application "Mail" to activate
end repeat
select pop up button 1 of group 1 of sheet 1 of window 1
tell application "Mail" to activate
keystroke (posixPath & "/" & newFolderName)
tell application "Mail" to activate
keystroke return
tell application "Mail" to activate
repeat until exists button 1 of sheet 1 of window 1
tell application "Mail" to activate
end repeat
tell application "Mail" to activate
click button 1 of sheet 1 of window 1
end if
end tell
end saveAttachments

on numberAdjust(theNumber)
set theNumber to theNumber as number
if theNumber = 0 then return "00"
if theNumber < 10 then return "0" & theNumber
return theNumber
end numberAdjust

on CreateFolder()
set WorkingDate to (current date) - (time to GMT)
set theYear to year of WorkingDate
set theMonth to my numberAdjust(month of WorkingDate as number)
set theDays to my numberAdjust(day of WorkingDate)
set theHours to my numberAdjust(hours of WorkingDate)
set theMinutes to my numberAdjust(minutes of WorkingDate)
set theSeconds to my numberAdjust(seconds of WorkingDate)
set newFolderName to (theYear & "-" & theMonth & "-" & theDays & " " & theHours & theMinutes & theSeconds & "Z") as text
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
end CreateFolder

 _______________________________________________
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/archives/applescript-users

This email sent to email@hidden

References: 
 >Mail: save attachment fails in Mountain Lion 10.8.2 (From: Neil Faiman <email@hidden>)
 >Re: Mail: save attachment fails in Mountain Lion 10.8.2 (From: Lists <email@hidden>)
 >Re: Mail: save attachment fails in Mountain Lion 10.8.2 (From: Neil Faiman <email@hidden>)
 >Re: Mail: save attachment fails in Mountain Lion 10.8.2 (From: Lists <email@hidden>)
 >Re: Mail: save attachment fails in Mountain Lion 10.8.2 (From: "koenig.yvan" <email@hidden>)
 >Re: Mail: save attachment fails in Mountain Lion 10.8.2 (From: Brian Christmas <email@hidden>)
 >Re: Mail: save attachment fails in Mountain Lion 10.8.2 (From: "koenig.yvan" <email@hidden>)

  • Prev by Date: Re: read a file - Lion vrs Tiger
  • Next by Date: Re: Snow Leopard/QuarkXpress Issue
  • Previous by thread: Re: Mail: save attachment fails in Mountain Lion 10.8.2
  • Next by thread: Entourage to Outlook snafu
  • Index(es):
    • Date
    • Thread