Re: Selecting messages in Outlook Express
Re: Selecting messages in Outlook Express
- Subject: Re: Selecting messages in Outlook Express
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 05 Mar 2003 18:15:03 -0800
On 3/5/03 3:42 PM, "Christian Boyce" <email@hidden> wrote:
>
I want to "get" every message sent to a given recipient in a given
>
folder ("Sent Items"). Then I'll do stuff to the list of messages that
>
I've gotten. Problem: I can't get the messages.
>
>
(We send email messages to our employees' phones to let them know about
>
calls that come into the office. At the end of the day, we want to
>
create a single document, containing all of the messages sent via email
>
to each employee.)
>
>
This works (the basics):
>
>
tell application "Outlook Express"
>
set themessagelist to every message in folder "Sent Items"
>
end tell
>
>
This also works:
>
>
tell application "Outlook Express"
>
set themessagelist to (every message whose subject contains "Jennifer")
>
in folder "Sent Items"
>
end tell
>
>
But this doesn't work:
>
>
tell application "Outlook Express"
>
set themessagelist to (every message whose recipient contains
>
"email@hidden") in folder "Sent Items"
>
end tell
>
>
It would be even better if I could further reduce the list of messages
>
by saying "Only messages sent today."
>
>
So far, it seems easy to filter things based on subject and sender but
>
not on recipient and not on date.
That's because 'recipient' is not a property of a message like all the other
things you're filtering for. Each recipient is a separate element of the
message. (OE has very kindly implement the 'recipient' property when making
a new outgoing message, allowing you to specify a list of recipients, or
even a single recipient outside a list, as part of the 'properties' record.
But that's actually a special coercion to make things easier for scripters.
When getting recipients of an existing message you have to get them as
elements.) Still, it's doable, as is date sent. You have to study the
Dictionary to see how the syntax works.
1) recipient:
Class recipient: Message recipient
Plural form:
recipients
Properties:
address address -- the recipient's address
recipient type to recipient/cc recipient/bcc recipient/newsgroup
recipient -- the type of recipient
Class address: An e-mail message address
Plural form:
addresses
Sub classes:
contact
Properties:
display name Unicode text -- the name used for display
address string -- the e-mail address
So a recipient is not a string, and can't 'contain' "email@hidden".
It's a record. The 'address' property of the recipient record is _also_ a
record. _Its_ address property (very confusing, this 'address' property IS a
string). That's what you're looking for. Finally, don't forget that a
message can have many recipients, of all recipient types: TO recipients , CC
recipients, and BCC recipients. If you want to confine yourself to just the
first recipient, you can do this with a straight 'whose' filter. 'first
recipient' behaves like a property. Otherwise you'll have to use a much
slower repeat loop through every message. So try this on for size:
tell application "Outlook Express"
set themessagelist to (every message of folder "Sent Items" whose
address of address of first recipient = "email@hidden")
end tell
(The first recipient will always be a TO recipient.) If you really need to
check every recipient you'll need to do this:
tell application "Outlook Express"
set themessagelist to {}
set theMessages to every message of folder "Sent Items"
repeat with i from 1 to (count theMessages)
set theMessage to item i of theMessages
if (address of address of every recipient of theMessage) contains
{"email@hidden"} then set end of themessagelist to theMessage
end repeat
return themessagelist
end tell
[Note that 'theMessages' is a list, and 'contains' should specify a list,
although it would coerce OK from a string.]
This is MUCH slower.
2). date sent:
Class outgoing message: An outgoing e-mail message
Plural form:
outgoing messages
Elements:
attachment by numeric index, satisfying a test
recipient by numeric index, satisfying a test
part by numeric index, satisfying a test
Properties:
--
time sent date -- (inherited from the 3message2 class) time at which the
message was sent
You also have to know something about the AppleScript date format. See the
AppleScript Language Guide.
By 'today' you mean any time between 12:00 am today and this very moment,
yes? So the limits would be:
set currDate to (current date) -- this very moment
set midnight to date (date string of currDate) -- 12:00 am
tell application "Outlook Express"
set todayList to (every message of folder "Sent Items" whose time
sent > midnight and time sent < currDate)
end tell
Note that you should put the two date definitions (or rather just the
second one with the 'date' object) OUTSIDE an Outlook Express (or any other)
tell block. Or else you'd need to say 'tell me to' (see below).
To combine your two requirements in one statement:
tell application "Outlook Express"
set currDate to (current date)
tell me to set midnight to date (date string of currDate)
set themessagelist to (every message of folder "Sent Items" whose
address of address of first recipient = "email@hidden" and time
sent > midnight and time sent < currDate)
end tell
--
Paul Berkowitz
_______________________________________________
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.