Mail.app Attachments Filter
Mail.app Attachments Filter
- Subject: Mail.app Attachments Filter
- From: NBurman Design <email@hidden>
- Date: Thu, 24 Jan 2008 10:22:18 -0700
Hi there
I'm trying to develop a script that will filter emails for me.
If I get an email with an attachment, I want the script to email my
Blackberry with a notification message, stating that I got an email
with an attachment. If there is no attachment, I want the email
simply forward to my Blackberry.
I have the following script in a rule, but every time it runs I get
''Error 8: NSInternal message'.
_____
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
repeat with eachMessage in theMessages
tell application "Mail"
try
set thesubject to subject of eachMessage
set theSender to sender of eachMessage
set bytes to message size of eachMessage
set thebody to content of eachMessage
-- conditional loop
set myAttachments to every mail attachment of
theMessages
if count (items of myAttachments) < 1 then
--do the forward of the email that has no
attachments
set newMessage to make new outgoing message
with properties {subject:thesubject & "From" & theSender,
content:thebody, sender:"email@hidden", visible:true}
tell newMessage
make new to recipient at end of to
recipients with properties {name:"Filtering",
address:"email@hidden"}
send
end tell
else -- send attachment notification
set newMessage to make new outgoing message
with properties {subject:"New mail + attachment", content:"You've got
a new message sent to Contact from " & theSender & ", Subject: " &
thesubject & ". Size of message: " & bytes & " bytes. ",
sender:"email@hidden", visible:true}
tell newMessage
make new to recipient at end of to
recipients with properties {name:"Filtering",
address:"email@hidden"}
send
end tell
end if
on error the error_message number the error_number
display dialog " Error: " & the error_number & ".
" & the error_message buttons {"Cancel"} default button 1
end try
end tell
end repeat
end perform mail action with messages
end using terms from
_____
Any and all insight gratefully appreciated!
~Nicholas
_______________________________________________
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