Moving from Microsoft Office VBA to AppleScript:
MacTech's Guide to Making the Transition
Introduction
|
Table of Contents
Page Prev and Page Next buttons at bottom of the page.
|
April, 2007
Page 118
However, there is a trick to it that works almost every time: run a script every 1 minute from a repeating Schedule. The script can check for all sorts of things, in particular whether there is a new draft window (new message window) in the front, and do nothing otherwise, but do whatever you need when it finds one and checks for other conditions. Since it should almost always take you more than a minute to write a message (and the average will actually be 30 seconds before the next schedule run), it can catch your message before you've finished writing it and add what you need. The next two scripts take advantage of that fact. [Ed. Note: be careful with this one, and bear the timing in mind. For short messages, you can certainly compose a message quickly enough and be out of sync with the scheduler. If you rely on this method, check your message before sending to make sure your script had a chance to run!]
Attach a vCard
Entourage has no setting to attach your vCard to outgoing messages. You can drag your "Me" contact from the address book to the message every time, but that soon becomes tedious. Instead run this script, which uses a cool technique, plus AppleScript's read/write commands and some Finder scripting to update your vCard, then attach it. If you're one of those people who likes to send your vCard on every message (well, I know there are people who do), set the script to run from a repeating schedule every 1 minute.
tell application "Microsoft Entourage"
set MUDpath to (path to MUD) as Unicode text
set meContact to me contact
set vcInfo to vcard data of meContact
set myname to name of meContact
end tell
set pathName to (MUDpath & myname & ".vcf") as Unicode text
try
set f to open for access file pathName with write permission
--will create a new one or update every time
set eof f to 0
write vcInfo to f
close access f
tell application "Finder"
set creator type of file pathName to "OPIM"
set file type of file pathName to "vCrd"
end tell
set theVcard to alias pathName
on error errMsg number errNum
try
close access f
end try
beep 2
return
end try
tell application "Microsoft Entourage"
try
if class of window 1 draft window then error number -128
< Previous Page Next Page>
- SPREAD THE WORD:
- Slashdot
- Digg
- Del.icio.us
- Newsvine