Filtering email
Filtering email
- Subject: Filtering email
- From: NBurman Design <email@hidden>
- Date: Mon, 28 Jan 2008 20:33:03 -0700
If anyone could give me a hand with this I'd appreciate it. I'm
stumbling through trying to learn Applescript and can't figure out
what I'm doing wrong (or rather, what the script is doing wrong).
This is meant to forward mail to my blackberry if there is not an
attachement, otherwise send an email saying that I have email with
attachments. It's in a rule that says 'If address is in address book,
run this script".
If there is no attachment, I get an error in Mail : "Error 8.
NSInternalScriptError" and no email is forwarded.
If there IS an attachment, I get an error in Mail: "Error -1700.
Can't make 0 into type boolean".
CODE:
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) = 0 then
-- forward the email that has no attachments
forward eachMessage
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
____________________________
Can anyone help? Thanks!
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