svv07

Members
  • Content count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About svv07

  • Rank
    Newbie
  • Birthday 12/07/1990

Contact Methods

  • MSN
    (ask me)
  • Website URL
    http://openreligion.net
  • ICQ
    437697242

Profile Information

  • Location
    Norway
  1. Below is the code from my first steps in to the applescript world. I was unsatisfied with the results produced by other scripts mentioned on this forum so I tried to make something that suited my needs better. I'm posting it here so you can try my scri_pt, comment on it, or adapt it to your needs. General description: SendToSpamCop for Mail.app takes the source-code of the selected mails and places it in a SpamCop-readable files in a folder on the users desktop. It then generates a mail with the forwarding address of the users SpamCop account as recipient. The scri_pt also attaches the generated files to this mail. I deliberately haven't added functionality to auto send the mail to SpamCop or to delete the generated SpamCop-folder on the desktop. Though this is not that hard to implement, I thought this would be better for both debugging purposes and for users who want to do something else with the generated files. Though the scri_pt can be run as it is, you may want to change the value of variable SCaccount in the code, before using it. How to do this is described in the first comments of the scripts source-code. If you don't feel like editing this variable the scri_pt would still work but you have to manually type your SpamCop forwarding address in the recipients field of the generated email. The scri_pt is open source so do with it what you like. But I would really appreciate it if you can leave some credits to the original author (me ). This is my first applescript coding attempt so comments and suggestions are appreciated. Here is the code: (* SendToSpamCop V1.0 written by S.J.L. v/d Velden The code below is open source and you may freely edit and redistribute it. Though I would appreciate it if you gave credits to the original author (me). -------------------------------------------------------- You have to customize a variable to make this scri_pt work with your SpamCop-account. Below you see the line that begins with "set SCaccount..." Replace the text YOURACCOUNT with the email address you've got from SpamCop.net to forward your spam to. *) -- set SCaccount to "YOURACCOUNT" (* Below is the rest of the sourcecode of the scri_pt. Please be very carefull editing this code *) -- Create a SpamCop folder on the desktop set theOutputFolderPath to path to desktop folder set theNewFolderName to "SpamCop" tell application "Finder" if (exists folder (theOutputFolderPath & theNewFolderName as string)) = false then make new folder at desktop with properties {name:theNewFolderName} end if end tell -- Create a new message in mail addressed to the users SpamCop account. Read the source from the selected messages in mail and save it as SpamCop readable file in the newly created SpamCop folder. Then attach each file to the new message. tell application "Mail" set theMessages to the selection set counter to 1 set theMessage to (make new outgoing message with properties {visible:true, subject:"report spam", content:" "}) repeat with thisMessage in theMessages set sourceFile to ((theOutputFolderPath & theNewFolderName as string) & ":ml" & counter & ".src") set thisSource to the source of thisMessage as string set f to open for access sourceFile with write permission set eof of f to 0 write thisSource to f close access f tell "Finder" set theAttachment to sourceFile as alias end tell tell the theMessage tell content make new attachment with properties {file name:theAttachment} at before the first character end tell end tell set counter to counter + 1 end repeat tell theMessage make new to recipient at end of to recipients with properties {address:SCaccount} end tell end tell