Script to create message from Note?

M

Michael Levin

Since Entourage doesn't sync Notes with the server, how about a script to
take all the notes and upload them to a special folder as emails (having
cleared that folder before each time)? This would be a pretty nice
workaround to the Notes problem, especially if that script could be timed to
run automatically every so often. Is this possible? Has someone done such a
thing, or is there a close example that one could tweak? I don't know much
about AppleScript programming but this sounds like it would be a very useful
thing if it could be done. What do people think?

Mike
 
P

Paul Berkowitz

Since Entourage doesn't sync Notes with the server, how about a script to
take all the notes and upload them to a special folder as emails (having
cleared that folder before each time)? This would be a pretty nice
workaround to the Notes problem, especially if that script could be timed to
run automatically every so often. Is this possible? Has someone done such a
thing, or is there a close example that one could tweak? I don't know much
about AppleScript programming but this sounds like it would be a very useful
thing if it could be done. What do people think?

What "server" are you talking about that's doing synching? Is this for an
Exchange account?

It would be really silly to keep deleting everything and remaking it all
again, dozens of times per day. But otherwise, yes: a script could make a
new draft message in a designated Exchange folder for every note whose
modification date and time is later than the last time the script ran.
(Putting up with a new message if you change something in an existing note
would be a lot simpler than searching for an existing message and modifying
that, for every note every time, but that could be done too by linking the
message to the note an checking for such a link. But then you'd also need to
run a reverse script to create notes from the messages on computers where
the note wasn't originally made, and link those. This could get very
complex.)

The only issue is that that the script cannot be made in the Panther or
Tiger Script Editor, since it requires a script property for the saved time
stamp, re-saved each time. Entourage's script menu does not re-save script
properties in "data fork" scripts, only in "resource fork" scripts, and
Script Editor no longer makes resource fork scripts: someone (like me) who
has the expensive Script Debugger would have to make and save the script.
There's no point my just posting the script text here because you wouldn't
be able to do anything with it. But I think Barry W. has a shell script that
can change a data-fork script to a resource-fork script. Barry? It's not on
your website - have you got it handy?


Here's the script. It will work once - now - to get all your existing notes
over. But don't run it again until you can get a copy saved as a resource
fork script, or it will remake all your note-messages every time it's run.
(When the blessed day comes, you can run it from an Entourage schedule.)

BTW - it adds your usual signature to the message.



property lastRunTime : date "1/1/1904"

tell application "Microsoft Entourage"
if exists (folder "Notes" of (get drafts folder of Exchange account 1))
then
set notesFolder to folder "Notes" of (get drafts folder of Exchange
account 1)
else
set notesFolder to make new folder at (get drafts folder of Exchange
account 1) with properties {name:"Notes"}
end if
set {myName, myAddress} to {name, default email address} of me contact
set newNotes to every note whose modification date is greater than
lastRunTime

repeat with newNote in newNotes
set {theTitle, theContent} to {name, content} of newNote
set newMessage to make new outgoing message with properties
{account:Exchange account 1, subject:theTitle, content:theContent,
recipient:{address:myAddress, display name:myName}}
move newMessage to notesFolder
end repeat

end tell



--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
B

Barry Wainwright [MVP]

The only issue is that that the script cannot be made in the Panther or Tiger
Script Editor, since it requires a script property for the saved time stamp,
re-saved each time. Entourage's script menu does not re-save script properties
in "data fork" scripts, only in "resource fork" scripts, and Script Editor no
longer makes resource fork scripts: someone (like me) who has the expensive
Script Debugger would have to make and save the script. There's no point my
just posting the script text here because you wouldn't be able to do anything
with it. But I think Barry W. has a shell script that can change a data-fork
script to a resource-fork script. Barry? It's not on your website - have you
got it handy?

A script can be converted quite easily in the terminal using the osacompile
command:
osacompile ­o /path/to/output/file /path/to/input/script

This can easily be wrapped in an applescript droplet.

However, I use the free Smile script editor, and that can still save
resource fork scripts that wrkin Entourage.

Having said that, in my more recent scripts I tend to use prefs files to
store data between runs, simply because I can't guarantee that a user won't
re-save one of my scripts. I usually do this (for a run date) with a:

do shell script "defaults write com.barryw.scriptName \"Last Run Date\"
'" & ((current date) as text) & "'"

To store the date, then a:

set lastDate to date (do shell script "defaults read
com.barryw.scriptName \"Last Run Date\"")

To read it back in again.
 
M

Michael Levin

What "server" are you talking about that's doing synching? Is this for an
Exchange account?

yep - for an exchange account. Am I wrong that the exchange account
doesn't sync notes and tasks in Entourage 2004?
It would be really silly to keep deleting everything and remaking it all
again, dozens of times per day.

once a day would be fine, I think.
But otherwise, yes: a script could make a
new draft message in a designated Exchange folder for every note whose
modification date and time is later than the last time the script ran.
(Putting up with a new message if you change something in an existing note
would be a lot simpler than searching for an existing message and modifying
that, for every note every time, but that could be done too by linking the
message to the note an checking for such a link. But then you'd also need to
run a reverse script to create notes from the messages on computers where
the note wasn't originally made, and link those. This could get very
complex.)

good point, although I'd certainly find it useful even if the notes went
only upstream and sat on the server as messages (were not translated back to
notes on clients where it wasn't originally made).
The only issue is that that the script cannot be made in the Panther or
Tiger Script Editor, since it requires a script property for the saved time
stamp, re-saved each time. Entourage's script menu does not re-save script
properties in "data fork" scripts, only in "resource fork" scripts, and
Script Editor no longer makes resource fork scripts: someone (like me) who
has the expensive Script Debugger would have to make and save the script.
There's no point my just posting the script text here because you wouldn't
be able to do anything with it. But I think Barry W. has a shell script that
can change a data-fork script to a resource-fork script. Barry? It's not on
your website - have you got it handy?
Here's the script. It will work once - now - to get all your existing notes
over. But don't run it again until you can get a copy saved as a resource
fork script, or it will remake all your note-messages every time it's run.
(When the blessed day comes, you can run it from an Entourage schedule.)
BTW - it adds your usual signature to the message.

thank you!!

Mike
 
Top