Re: Mail.app: set content of message generates unexpected error
Re: Mail.app: set content of message generates unexpected error
- Subject: Re: Mail.app: set content of message generates unexpected error
- From: Dan Doughtie <email@hidden>
- Date: Mon, 27 Oct 2003 23:35:54 -0500
I wasted most of a day trying to script Mail under 10.3. Two things. The App
MAIL is a new version with 10.3. The syntax changed somewhat but
unfortunately you might be trying to do something that isnt' possible. First
of all, are you trying to clean up your mail before you read it or before
you pass it on?
Why? Incoming messages are read only for a purpose. An incoming message is a
document that on purpose can't be altered or else how would you know the
message sent hasn't been doctored. An email is supposed to be a record of
what someone said or did. The limit to the "editing" of the email is to
search the content and if something is offensive then you say "I don't want
to see it.
Think about it. You can't open a mail manually and edit it. Why would you be
able to do likewise with a script?
Now, if you want take the data out of the incoming message and create a
new message (pretty much same process as manually replying or forwarding.
You can edit those) you then you can use your snipped email. Then send it to
yourself from your own account or do like I did in a script, write it out as
a text file in a special folder based on the sender.
Now here's the problem I had and I think it is a bug. I was able to gather
the content and reuse it but under 10.3 the content became a "?" 70% of the
time.
Dan
>
From: Matthew Rothenberg <email@hidden>
>
Date: Mon, 27 Oct 2003 17:13:49 -0500
>
To: <email@hidden>
>
Subject: Mail.app: set content of message generates unexpected error
>
>
I have been able to successfully make a number of applescripts that act upon
>
the content of incoming messages in Mail.app via Rules. What I want to be
>
able to do is use these to do things like stripping certain characters, etc.
>
(In particular, I want to remove the pagelong disclaimer that gets appended
>
to every email my girlfriend sends me).
>
>
I can get to the point where I have a string containing the "santized"
>
message text. My problem is getting that text to replace the existing
>
message text. Despite "content" in class "message" not being listed as
>
read/only, Mail.app generates an error when I try to set it.
>
>
I am using code that looks somewhat like this
>
> using terms from application "Mail"
>
> on perform mail action with messages theMessages for rule theRule
>
> tell application "Mail"
>
> repeat with eachMessage in theMessages
>
> [...snip...]
>
> set the content of eachMessage to newTxt
>
> end tell
>
> end perform
>
> end using terms from
>
>
And it ends up dumping an error that looks like this:
>
> set content of message 2 of mailbox "INBOX" of account "NYU CAT" to
>
> "testing..."
>
> "Mail got an error: NSInternalScriptError"
>
Not a very helpful error message I know.
>
>
Caveat: I can set other properties of the message object just fine,
>
changing the read status (bool) or subject (plain text) work just fine, and
>
the change is reflected instantly in Mail.app. The problem seems to only
>
happen when I attempt to set the content property.
>
>
I've wasted an entire day on what should have been a simple script... Any
>
help is appreciated!
>
>
FWIW, this is in OSX10.3.
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.