On 2/2/01 11:49 AM, "Bryan Harris" <[EMAIL PROTECTED]> wrote:

> 
> 
> (I would ask this to Paul directly, but I thought others might be interested
> as well..)
> 
> 
> Is there a way to script the attaching of a certain file to a message?
> 
> i.e. Given an open draft window, run the script and have it attach a pre-set
> file to the message.
> 
Yes. The "short version" is to say
    
    set theDraft to window 1 -- if that's where it is
    set theFile to alias "Your HD:Some Folder:Some File"
    make new attachment at theDraft with properties {file:theFile}

If it's on the desktop, that "Some Folder" would be "Desktop Folder". You
can specify other properties, such as encoding and compression: otherwise it
will use your regular default settings.

'attachment' can also act like a property as well as an individual element
in a message or draft window, and then it is a list of all the attachments.
In this case, you need to do it at 'creation' point:

    set theAttachments to {{file:alias "PB HM Hard Disk:Desktop Folder:Word
11 Wishlist.doc"}, {file:alias "PB HM Hard Disk:Desktop
Folder:PrintEnvelopes.sit"}
    make new draft window with properties {subject:"Test",
attachment:theAttachments}


In this case, you'd find it better to set encoding and compression
properties of the draft window or outgoing message itself than for the
individual files. If there's just one attachment, it will work with just the
single set of record braces

    {file:alias "PB HM Hard Disk:Desktop Folder:PrintEnvelopes.sit"}

or is fine with the surrounding set of list braces:

   {{file:alias "PB HM Hard Disk:Desktop Folder:PrintEnvelopes.sit"}}
    
so it works even if you don't know how many there will be and you get it
from a repeat block. That "file: " property has to be specified for each
ossurrenece. (Ignore the underlining here: that's an email thing for URLs
activated by the word 'file' in yet another context.)


One important word of warning: don't attempt to use the term 'file' meaning
an applescript reference to a file on your computer when you're within an
Entourage tell block, since it has that specific meaning for the attachment
property as above, and won't work for anything else. Always use 'alias' to
mean the same thing, as I did. This gets very tricky when you're trying to
save an attachment from an _incoming_ message to your hard disk. Here you
_have_ to be in a tell block, and the file doesn't exist yet so you can't
use 'alias'. Here's the solution:

    save theAttachment  in "Your HD:Some Folder:Some File" as file
specification

Although usually, you'll find that just

     save theAttachment  in "Your HD:Some Folder:Some File"

will work, but that's due to a silent coercion from Jon's Commands or Akua
Sweets osaxen if you have them, which won't work if users don't have them.
That's where 'as file specification' does the trick.

-- 
Paul Berkowitz


-- 
To unsubscribe:               <mailto:[EMAIL PROTECTED]>
To search the archives: 
          <http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>

Reply via email to