Re: funny FM/AS/OE behavior - Help!
Re: funny FM/AS/OE behavior - Help!
- Subject: Re: funny FM/AS/OE behavior - Help!
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 10 Dec 2002 17:56:42 -0800
On 12/10/02 5:11 PM, "Gary Lists" <email@hidden> wrote:
>
On or about 12/10/02 7:28 PM, Paul Berkowitz wrote:
>
>
> If the content is complete, you don't need you open it up on the screen. You
>
> could make a message and send it without opening it. But then you would have
>
> to turn bccList into a list of records.
>
>
That's cool. What do you then need to change "set newMsg to make new draft
>
window" to? Or just make it "in outbox"?
set newMsg to make new outgoing message in out box folder with
properties {...}
If you omit the location, it gets made by default in the drafts folder (or
IMAP drafts folder, if it's an IMAP account).
But the list of properties for recipient property is very awkward to
assemble. The complexity depends on whether that original comma-delimited
'bccList' contained display names as well as email addresses. Entourage (and
OE) have some undocumented shortcuts for recipient which you may have
stumbled upon in other scripts, but these don't work if you need cc or bcc
recipients. or only up to a point. The structure of 'recipient', as dictated
by Apple's old Mail Suite, is quite Byzantine. Whereas, if you have just
one recipient:
"Joe Blow <email@hidden>"
or
"email@hidden"
you can just make the recipient property:
recipient:"Joe Blow <email@hidden>"
that's actually a kind coercion implemented by the developers. Strictly
speaking, it should look like this:
recipient:{{address:{address:"email@hidden", display name:"Joe Blow"},
recipient type:(to recipient)}}
So if you have a slew of them, you need to assemble your list carefully. You
can omit recipient type if it's (to recipient), you can omit display name if
there isn't one (or else make it ""), you can omit the {address:(address: }}
construct if you omit display name and make it just {address: }, etc. If
there's just one recipient, you can omit the outer list brackets. But if you
don't know what might come up, use the whole thing. It often means you have
to parse "Joe Blow <email@hidden>" format into its constituent display name
and address parts, and take account of the fact that some may in fact be
just "email@hidden" format. I put (to recipient) in parentheses because
OE/Entourage, or AppleScript, sometimes get confused by the 'to' word.
Suppose you already have separate lists (real Applescript lists) for to
recipient, cc recipients, and bcc recipients: toRecips, ccRecips, bccRecips.
(If you have those comma-delimited strings, do it with tids. Be ware that
there might be a space as well as a comma.)
set theRecipients to {}
tell application "Microsoft Entourage"
repeat with i from 1 to (count toRecips)
set toRecip to item i of toRecips
set AppleScript's text item delimiters to {" <"}
try
set eAddress to text item 2 of toRecip
set AppleScript's text item delimiters to {">"}
set dname to text item 1 of toRecip
set eAddress to text item 1 of eAddress
on error
set eAddress to toRecip
set dname to ""
end try
set AppleScript's text item delimiters to {""}
if eAddress contains "@" then -- otherwise skip this one
set end of theRecipients to {address:{address:eAddress, display
name:dname}, recipient type:(to recipient)}
end if
end repeat
-- do the same thing for ccRecips and bccRecips, appending each
recipient to toRecipients list with the appropriate recipient type
set newMsg to make new outgoing message at out box folder with
properties {subject:"foo", content:"bar", recipient:theRecipients}
send newMsg
end tell
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.