In order to save my Blackberry data plan from costing me a small mortgage, I want to filter all mail using mail.app.
I have set up a rule that says ‘if any attachment ends in pdf, jpg, gif, eps or ai, label it red’. The next step is to apply an Applescript that sends an email to my blackberry address saying ‘Hey, you got mail with an attachment’ - and possibly saying who it’s from.
All mail without attachments can be sent to the Blackberry (according to my rules!) but I only want the attachment ones to ONLY send an email announcing arrival. No forwarding.
Since I know less than nothing about Applescript, does anyone know where I can get a script? Or would some kind soul be nice enough to send me one that would work?
Thanks!
~NIck
Model: Powerbook G4 (Thresher)
Browser: Safari 523.12.2
Operating System: Mac OS X (10.4)
Hi Nick,
Try saving the script below into your /Library/Scripts/Mail Script/Rule Actions folder, then add another action to your existing rule and set it to “Run Applescript” and choose the script.
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
repeat with eachMessage in theMessages
tell application "Mail"
set mysubject to subject of eachMessage
set theSender to sender of eachMessage
set newMessage to make new outgoing message with properties {subject:"Hey, you got mail with an attachment", content:"You've got a new message from " & theSender}
tell newMessage
set visible to true
make new to recipient at end of to recipients with properties {name:"mytest", address:"youremail@here.com"}
send
end tell
end tell
end repeat
end perform mail action with messages
end using terms from
How would I change it so that it does forward mail without attachments ?(I know nothing about Applescript!)
~Nick
PS I tested it a couple time and it doesnt send a message to my Blackberry. This is exactly what I put in my script:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
repeat with eachMessage in theMessages
tell application "Mail"
set mysubject to subject of eachMessage
set theSender to sender of eachMessage
set newMessage to make new outgoing message with properties {subject:"New mail with an attachment", content:"You've got a new message sent to contact from " & theSender}
tell newMessage
set visible to true
make new to recipient at end of to recipients with properties {name:"Filtering", address:"nburman@rogers.blackberry.net"}
send
end tell
end tell
end repeat
end perform mail action with messages
end using terms from
Hi Nick,
I tested the script on my laptop running 10.4.11 and it works fine. What OS are you running?
I can’t see any problems with your rule setup.
Can you see a sent message in your sent items? Need to establish if it’s creating the new message in the first place. You could try to comment out the send command i.e.
--send
and then it’ll just create a new message at the front of Mail. Please let me know how you get on.
Thanks,
Nik
Hi Nick,
That makes me think that it maybe a problem with the rule rather than the script. Do your messages that contain the specified attachment change colour? If so, maybe you could try simplifying the rule so that it’s something like “If any subject contains the word test” then colour the message and perform the script?
Thanks,
Nik
I made a simpler rule - if subject contains ‘test’, colour it green and run the script. Still nothing on my Blackberry, and nothing in the Sent folder.
I tested to make sure my BB can receive mail, and it does.