Re: Searching a Mail message
Re: Searching a Mail message
- Subject: Re: Searching a Mail message
- From: deivy petrescu <email@hidden>
- Date: Sun, 3 Jun 2007 21:21:21 -0400
On Jun 3, 2007, at 10:32, Philip Aker wrote:
On 2007-06-03, at 07:21:50, deivy petrescu wrote:
Some people tend to undermine AS abilities.
May be my problem is I tend to overestimate its capabilities and
can not go past it.
Here's your script adapted to work with Mail. When I run it on
your post I'm replying to, it doesn't produce an acceptable result.
Philip,
I beg to disagree. It produces perfect results.
You're kidding right?
Certainly not!
Reread my message. I said I cheated a bit.
Yes, you admitted you cheated. The object is to get valid email
addresses from the content of an email message. So your code
getting them from a fixed text item doesn't solve much. See my
reply to Doug MacNutt for an alternate. Leaving the solution as an
exercise is not proof of viability.
Philip,
Actually, your answer to Doug jut proves my case. This, my cheap way,
got all email addresses, which, you did not do with you "better" way.
The only problem I've left out on the first script was that hard
returns and no space make it for another word.
This is not particularly difficult to get rid of.
However, the problem of getting only correct email addresses requires
more work on the part of the o.p. and it depends on the habits of the
people who write.
As I said, "meet email@hidden is great" is kind of hard to decide is not
an email address.
Also "email@hidden" will include the " at the beginning and at
the end. So write a script to remove all spurious symbols.
Here is the homework you did not wanted to do (includes getting the
text from the current mail message)
<script>
tell application "Mail" to set m to content of item 1 of (get selection)
set m to change {m, ASCII character 10, space}
tid("@")
set emails to {}
set q to text items of m
tid(space)
repeat with j from 1 to ((count q) - 1)
if (text item -1 of text item j of q) ≠ "" and (text item 1 of text
item (j + 1) of q) ≠ "" then set end of emails to (text item -1 of
text item j of q) & "@" & (text item 1 of text item (j + 1) of q)
end repeat
tid("")
emails
on tid(x)
set AppleScript's text item delimiters to x
end tid
on change {texto, x, y}
tid(x)
set texto to text items of texto
tid(y)
return texto as Unicode text
end change
<script>
Which returned using your reply:
--{"me@3PM\"", "tid(\"@\")", "\"@\"", "{\"\\\"@\\\"\",", "tid(\\\"@\\
\")", "\"\\\"email@hidden\",", "\"email@hidden
\",", "\"email@hidden\",", "\"\\\"@\\\"\",", "---{\\
\"email@hidden\\\",\",", "\"\\\"email@hidden\\
\",\",", "\"\\\"email@hidden\\\"}", "\"(applescript-
email@hidden)", "\"email@hidden", "(applescript-
email@hidden)", "email@hidden"}
Now as another hw, I'll ask people to remove the \", ), (, etc. from
each email.
Ah! All the email addresses are there. Check.
Deivy _______________________________________________
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