Hi,


First of all, if there is another way other than applescript that also does the trick, that is also fine.

I've been searching the web for a script to save all the attachments from my email to a local folder (Or network folder) and then delete them using applescript.
I came acros alot of script but all of them don't save my actual attachment, the best script I found deleted the attachment and added a line in the email saying the attachment was deleted. I tried so many scripts, trying to combine and edit them but they all don't seem to save my attachments.

so somehow the this part of saving does not work

     save a in “/Users/****/Desktop/” & id of msg & “/” & name of a

Is there a change in code maybe? Cause the posts are from 2 years ago.

tell application "Microsoft Outlook"

set msgs to current messages

set sz to 0

repeat with msg in msgs

set theName to subject of msg

set fixName to theName as string

set AppleScript's text item delimiters to "/"

set theString to text items of fixName

set AppleScript's text item delimiters to " "

set fixName to theString as string

set AppleScript's text item delimiters to ""

log "Subject: " & subject of msg

tell application "Finder"

set p to path to desktop

make new folder at p with properties {name:fixName}

end tell

set fileDownloadedList to "Attachments Removed:<br>------------------------<br>"

if msgs is {} then

display dialog "Please select a message first then run the script" with icon 1

return

end if

set atts to attachments of msg

repeat with att in atts

set a to att

try

set asz to file size of a

save a in "/Users/ssbg/Desktop/" & fixName & name of a

set sz to sz + asz

set fileDownloadedURL to "file://localhost" & my path2url(POSIX path of fileDownloaded)

set fileDownloadedList to fileDownloadedList & "Attachment:  <a href=\"" & fileDownloadedURL & "\">" & fileDownloaded & "</a><br>"

on error

exit repeat

end try

end repeat

set content of msg to fileDownloadedList & "<br>" & content of msg

set attachmentCount to count of atts

repeat (attachmentCount) times

delete item 1 of atts

end repeat

end repeat

end tell

Thanks,

Sandy

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.