I am used to Windows based platform scripting, but as I have changed jobs, I am now in a Macintosh based office and do not know much about scripting on the Macintosh/Entourage/Applescript platforms, I would welcome anyone’s help in this area.
I deal with a lot of Real Estate Agents that request photos or logos, so I have set up a simple request photo script on the site, which sends an email with a “photoId” in the subject.
What I need is a script in Entourage 11.1.0 that can do the following.
a.) Get the email address from the person that has just sent the email, store that in a variable say “emailAddress” then
b.) Get the subject, eg. “Photo Request 1234” and just get the digits and store that in a variable say “photoId”
c.) Get the corresponding “photoId” image from a directory set up on a Macintosh based file server.
Say, 1234 will be 1234.jpg found in the ImagesLowRes folder on the server.
d.) Attach that image in a new email and send it off to the original “emailAddress”
Thankyou again to all, and I welcome either an answer via here or feel free to contact me on my work email
Check out your Documents > Microsoft User Data > Entourage Script Menu Items folder. There are a few examples that will point you in the right direction for using AS with Entourage.
The Applescripts that come with your OS ( Applications > AppleScript) are pretty good for general use stuff like file references, etc.
As you have previous scripting experience, this could get you started:
--> define vars
property theDir : alias "disk:dir:lowRes:"
tell application "Microsoft Entourage"
--> pick subject and from field
set msg to item 1 of (get current messages)
set {x, y} to {last word of (get subject of msg), address of sender of msg}
--> compose answer
set outMsg to make new outgoing message at out box folder with properties {subject:"Your request for thing: " & x, to recipients:y, attachment:((theDir as text) & x & ".jpg") as alias}
send outMsg
end tell
I have a question in regards to attachments. I want to create a new message with the original message attached to the new one. I keep getting an error.
This is what I have tried sofar.
property emailAddress : "myaddress"
property theSubject : ""
tell application "Microsoft Entourage"
set counter to count of messages in folder id 6 --this is the JunkE-mail folder
repeat with i from 1 to counter
set fwdMessage to message i in folder id 6
set newMsg to make new draft window with properties ¬
{recipient:{address:emailAddress, recipient type:to recipient}, subject:theSubject, content:theSubject, attachment:(fwdMessage) as alias}
send newMsg
end repeat
end tell -- Entourage
I have only gotten errors that says:“Can’t make «class inm » id 41630 of application "Microsoft Entourage" into type alias.”
An attachment is a “physical” document in your disk, so you must attach an existing document in your disk. Eg:
property emailAddress : "myaddress"
property theSubject : ""
tell application "Microsoft Entourage"
set counter to count of messages in folder id 6
repeat with i from 1 to counter
set fwdMessage to message i in folder id 6
--> save msg to temporary location
set tempMsg to ("/tmp/msg" & ID of fwdMessage) as POSIX file
save fwdMessage in tempMsg
set newMsg to make new draft window with properties ¬
{to recipients:{emailAddress}, subject:theSubject, content:theSubject, attachment:tempMsg}
--send newMsg
end repeat
end tell