** Pastebin PRO Accounts Easter Special ** Get 40% discount for a limited time only! Click Here to check it out ;-)Want more features on Pastebin? Sign Up, it's FREE!

Applescript to fix emails with hidden attachments

By: a guest on Jan 30th, 2013  |  syntax: AppleScript  |  size: 1.08 KB  |  views: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. set newFileName to (path to temporary items folder from user domain as string) ¬
  2.         & (random number from 10000 to 99999) ¬
  3.         & ".eml"
  4. tell application "Mail"
  5.         set selectedMails to the selection
  6.         if the length of selectedMails is greater than 0 then
  7.                 repeat with theMessage in selectedMails
  8.                         set newSource to my replaceText("Content-Type: multipart/related;", "Content-Type: multipart/mixed;", source of theMessage)
  9.                         set newFile to open for access newFileName with write permission
  10.                         write newSource to newFile starting at 0
  11.                         close access newFile
  12.                         open newFileName
  13.                 end repeat
  14.                 tell application "Finder" to delete file newFileName
  15.         else
  16.                 display alert "Selezionare uno o più messaggi e riprovare"
  17.         end if
  18. end tell
  20. on replaceText(find, replace, someText)
  21.         set prevTIDs to text item delimiters of AppleScript
  22.         set text item delimiters of AppleScript to find
  23.         set someText to text items of someText
  24.         set text item delimiters of AppleScript to replace
  25.         set someText to "" & someText
  26.         set text item delimiters of AppleScript to prevTIDs
  27.         return someText
  28. end replaceText
clone this paste RAW Paste Data