Re: Scripting Entourage, is this possible?
Re: Scripting Entourage, is this possible?
- Subject: Re: Scripting Entourage, is this possible?
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 17 Nov 2006 15:09:03 -0800
- Thread-topic: Scripting Entourage, is this possible?
Title: Re: Scripting Entourage, is this possible?
On 11/17/06 2:23 PM, "Michael Curtis" <email@hidden> wrote:
I am new to Applescript, but I have a project I would like to try and write. He is what I need to do, but before I start I would like to know it is doable. I am not looking for the answer, I would like to try and work it out for myself, but if I get stuck I may be back :-)
- I need to save the opened, or highlighted email as an, Entourage Email Message. The file can have the same name each time or use the subject line.
Yes. (But it's not a file.) And I don't think you mean 'save'. You actually want to make a new copy, right? Yes, you can make a new incoming message with all (or many as you want) of the properties of the existing one. You'll want to investigate 'make new incoming messages with properties{...} ', 'source' property of message, and know that the way to get a selected message (including the one open on the screen) is
item 1 of (get current messages).
You need the explicit 'get' there. If the window in the front is not an existing received message but a new unsaved message window, then it's not a message, not even an 'outgoing message'. It's a 'draft window', and you can save it to a folder using 'save front window' with no parameters. (The Dictionary doesn't tell you this; that's why I am.) Make all your changes to the 'draft window' before saving it. It saves it to the Drafts folder, but you can find it there as an 'outgoing message' by getting the 'displayed message' of the front window. You can later tell the window to 'close saving no' (or yes).
b) I then need to reattached it to a new message and send it to a specified address.
Yes, you can do that. Be ware that you can actually make a new new message in the drafts folder or outbox without having to open it. (If you wanted it open you'd probably make it as a new draft window instead), specifying among the 'with properties {...}' an 'attachment' property, which can be a single attachment or a list of attachments. Again the dictionary doesn't say you can do it this way. (This is a lot easier than making new attachments as elements: in fact you can't even do that for a message, only for a draft window. So do it by using 'attachment' property.)
Now you'll discover that the way of specifying an attachment is via {file:whatever} where 'whatever' is of type 'alias' - i.e. a file on your computer. But an Entourage message is not a file on your computer. So how do you do this? You have to save the message to disk (maybe that's what you were asking in the first place?) and use the saved file as your alias. OK, so how to save to disk?
Use the 'save' command from the Standard Suite. For your 'in' parameter, you must use the full path of your desired file, but as Unicode text. NOT as 'alias' (since it doesn't exist yet) not as 'file' which will error since it conflicts with Entourage's own 'file' class. This could be a problem, but it isn't, since using the text path works.
Get the name of the file-to-be from the subject of the message, but first run it through a search-and-replace routine using AppleScript's text item delimiters to replace colons ":" by "-". Otherwise you'll get an error. (And lots of email messages have colons, especially ones beginning "Re: " or "FW: " so this is essential.) Then tack an ".eml" extension on the end. You can make the message in any location including the desktop but then you have to get rid of it afterwards: so do what Entourage foes and make it in the Entourage Temp folder in the Microsoft User Data folder (which you can discover using the 'path to MUD' property of the application). You can coerce it to Unicode text, add the subject and ".eml" and save it there. (Note: there is a shortcut that lets you save it 'in' the Entourage Temp folder (or any other) as Unicode text: i.e. instead of all that effort removing colons plus another routine in case a file of that name already exists, this shortcut lets you save it 'in' the text path of the containing folder! (This is not supposed to work, and does not for most applications., but I believe it does so for Entourage.) However then you can't get hold of the file. By doing the routines yourself, you'll know exactly what the name of the alias is and can find it immediately to then use as the 'file' property for 'attachment'.
I am assuming b) is pretty simple, but a) might not be. Where is the best place to find the Applescript commands Entourage supports?
In its Dictionary, of course. (In Script Editor. File/Open Dictionary, and select or browse to Microsoft Entourage.)
--
Paul Berkowitz
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden