PDA

View Full Version : AppleScript Inquiry




US8
Apr 11, 2008, 03:09 PM
We are using a 3rd-party software application on a system running Leopard v10.5.2. The following script is one of a number of scripts that are part of this application:

<http://home.comcast.net/~tyh/OMScript.jpg>

When this script is run, the application invokes Apple's "Mail" program and attaches images as an attachment, however we have a need to change the script to invoke "Entourage" instead of "Mail". Our request is fairly basic -we are seeking instructions on what line(s) to change (tell application "Mail" ??), especially the code which relates to setting the attachments via Entourage? Once we modify the script, is re-compiling required prior to placing it back into commission, and how do we do this?

Thank you in advance to all who offer their advice and expertise.



lee1210
Apr 11, 2008, 03:14 PM
I didn't look at the script, but what you want to do is open script editor, under the file menu, choose "Open Dictionary...", then choose Microsoft Entourage.

There is a message "noun", which contains an attachment element. There is a send action which acts on a message. With a combination of those you should be able to put it together.

-Lee

US8
Apr 11, 2008, 06:51 PM
Lee,

We apologize for our ignorance, but we are not versed at all in scripting, let alone ensuring that all pieces of the puzzle are correct. Please look at script and suggest revisions to change program from "Mail" to "Microsoft Entourage" as well as adjust portion of script which opens "Entourage" attachment rather than "Mail".

Thank you.

lee1210
Apr 11, 2008, 11:09 PM
on open theList
tell application "Microsoft Entourage"
activate
set newMessage to (make new outgoing message)
repeat with aFile in theList
make new attachment at newMessage with properties {file:aFile as alias}
end repeat
end tell
end open

From what I could tell of the original script, no message was sent, just created. This achieves the same thing. There will be a draft message that is completely empty except for having the list of files dropped on the script added as attachments.

-Lee

US8
Apr 12, 2008, 09:25 PM
Lee,

Apologies in advance for our lack of experience in this area, but we tried what you suggested and 5 variations of the original script without success (see actual scripts below):

Script 1 - Entourage launches successfully, but no new message is created

Script 2 - Entourage launches successfully, but script error pops up "The variable pathToFile is not defined"

Script 3 - script does not even launch

Script 4 - Entourage launches successfully, but no new message is created

Script 5 - script does not even launch

Again, this is a photo program where we select one or a number of images and then press the email option. At this point, the script should start by opening Entourage and attaching the image(s) to a blank email; the script should then end and allow the user to add text, title, recipient, send the message.

We are seeking further guidance. Thank you.

--------------------

Script1

on open theList

set SendFileList to {""}
repeat with anItem in theList
set SendFileList to SendFileList & {anItem as alias}
end repeat


tell application "Microsoft Entourage"
activate
set newMessage to (make new outgoing message)
repeat with aFile in theList
make new attachment at newMessage with properties {file:aFile as alias}
end repeat
end tell
end open

--------------------

Script2

on open theList

set SendFileList to {""}
repeat with anItem in theList
set SendFileList to SendFileList & {anItem as alias}
end repeat


tell application "Microsoft Entourage"

activate
set theMessage to make new outgoing message with properties {subject:"This is your file", content:"Attached is your file.", recipient:{address:{address:"somebody@example.com", display name:"I. M. Somebody"}}, attachment:alias pathToFile}
end tell
end open

--------------------

Script3

on open theList

set theList to ""
set SendFileList to {""}
repeat with anItem in theList
set SendFileList to SendFileList & {anItem as alias}
end repeat

set SendFileList to "Cassandra:Users:masahiro_takeda:desktop:test1.txt" as alias

tell application "Microsoft Entourage"
activate
set newMessage to make new draft window with properties {to recipients:"email to @ whom ever", subject:"test mail"}
make new attachment at newMessage with properties {file:SendFileList}
end tell
end open

--------------------

Script4

on open theList

set SendFileList to {""}
repeat with anItem in theList
set SendFileList to SendFileList & {anItem as alias}
end repeat


tell application "Microsoft Entourage"

-- set SendFileList to {"Cassandra:Users:masahiro_takeda:desktop:test.txt" as alias}
-- set SendFileList to {"Cassandra:Users:masahiro_takeda:desktop:test1.txt" as alias} & SendFileList

activate
set newMessage to (make new outgoing message)
repeat with aFile in theList
make new attachment at newMessage with properties {file:aFile as alias}
end repeat
end tell
end open

--------------------

Script5

on open theList
tell application "Microsoft Entourage"
activate
set newMessage to (make new outgoing message)
repeat with aFile in theList
make new attachment at newMessage with properties {file:aFile as alias}
end repeat
end tell
end open

lee1210
Apr 12, 2008, 10:48 PM
The script I provided above should do what you need.

-Lee

US8
Apr 13, 2008, 10:52 AM
Lee,

Script5 is your script, but it does not even launch from the program. We believe this program requires something else above your code to even launch Entourage.

We tried two other scripts without success:

Script1 - script does not even launch

Script2 - script does not even launch

If you're willing to test it yourself, the program is "Olympus Master 2" and can be downloaded from:

<https://emporium.olympus.com/studioMaster2/OlympusMaster.aspx>

The script is titled "OMScript" and is located under the package contents of the main application file (Olympus Master 2) in the Resources folder.

Thank you for any additional guidance.

-----------------------------------

Script1

on open tList

tell application "Microsoft Entourage"
activate

set nMessage to make new draft window with properties {to recipients:"email@mailinator.com"}
repeat with i in tList
make new attachment at nMessage with properties {file:i}
end repeat

end tell

end open


Script2

on run
set tList to choose file with multiple selections allowed
open (tList)
end run

on open tList

tell application "Microsoft Entourage"
activate

set nMessage to make new draft window with properties {to recipients:"email@mailinator.com"}
repeat with i in tList
make new attachment at nMessage with properties {file:i}
end repeat

end tell

end open

lee1210
Apr 13, 2008, 03:39 PM
I downloaded the application in question and found where in the package to replace OMScript.

The script I provided works as explained. You need to enter it in script editor, then do "Save As..." and choose "application" for the format.

Do this, then replace the OMScript that exists, and try again.

-Lee

US8
Apr 13, 2008, 05:40 PM
Lee,

We are using Entourage v12.0.1 on an Intel-based Mac running v10.5.2. We were missing the crucial step of re-saving the script as an "Application" under SaveAs. With this correction, your script does load up Entourage, but it still does not launch a new message and attach images (not sure why this one doesn't work with our configuration). However, we re-saved the following script and it loads up Entourage, loads new draft message, and attaches all images:

on open tList

tell application "Microsoft Entourage"
activate

set nMessage to make new draft window with properties {to recipients:"email@mailinator.com"}
repeat with i in tList
make new attachment at nMessage with properties {file:i}
end repeat

end tell

end open

Thank you for all the effort you put into helping us with this dilemma. All the best to you.

US8

lee1210
Apr 13, 2008, 06:25 PM
I'm running Entorage 2004 (11.4), on 10.4.11. I'm guessing the difference in the entourage is the cause for the differences of the script behavior. Glad you got it working.

-Lee