Paul
Fri May 14 23:42:14 CDT 2004
> This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--B_3167415734_2928848
Content-type: text/plain;
charset="ISO-8859-1"
Content-transfer-encoding: 8bit
set currentMessage to the draft window
doesn't make any sense. You have to specify _which_ window. And if there
isn't one it wouldn't be an empty list {}, it would simply error. Later on,
there's another error with categories - draft windows don't have a category
property so you can't get the category "specs". Then you have another error
where you try to use the variable 'theName' which is undefined, at least in
the part of the script you sent. Then there's another error in that you
can't make a 'new message': it has to be a new 'outgoing message'. (Assuming
that you don't simply want to make a new draft window.)
This will work:
tell application "Microsoft Entourage"
display dialog "Done with part 1" with icon 1
-- get the message we're working on into a variable
set currentMessage to window 1
-- if there is no message to duplicate, warn the user and then quit
if class of currentMessage ? draft window then
display dialog "Sorry, there is no message for me to duplicate.
Waah!" with icon 1
return
end if
-- grab the data from the message draft window
set theSubject to (subject of currentMessage)
set theContent to (content of currentMessage)
-- create a new message with the information from the current message
set newMessage to make new outgoing message with properties
{subject:theSubject, content:theContent}
-- open the new message we just created
open newMessage
end tell
-----------------------
Here's a version that will include the category. You have to save the draft
window. then get the 'displayed message' of that window.
tell application "Microsoft Entourage"
display dialog "Done with part 1" with icon 1
-- get the message we're working on into a variable
set frontWindow to window 1
-- if there is no message to duplicate, warn the user and then quit
if class of frontWindow ? draft window then
display dialog "Sorry, there is no message window for me to
duplicate. Waah!" with icon 1
return
end if
save frontWindow
set currentMessage to displayed message of frontWindow
-- grab the data from the message draft window
set theSubject to (subject of currentMessage)
set theCategory to (category of currentMessage)
set theContent to (content of currentMessage)
-- create a new message with the information from the current message
set newMessage to make new outgoing message with properties
{subject:theSubject, content:theContent, category:theCategory}
-- open the new message we just created
open newMessage
end tell
--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <
http://www.entourage.mvps.org/toc.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 Entourage you are using - **2004**, X
or 2001. It's often impossible to answer your questions otherwise.
> From: Auri Rahimzadeh <auri@rahimzadeh.com>
> Newsgroups: microsoft.public.mac.office.entourage
> Date: Fri, 14 May 2004 18:26:12 -0500
> Subject: Access Message Draft Window in Applescript
>
> I want to duplicate a mail message in Applescript... so I want to be
> able to read the current message draft window and create a new message
> based on its contents using an Applescript... any ideas? Here's my
> (poor) code... The error I'm getting is "Can't get subject of draft
> window." and then it quits. The script *does* compile fine. Any help
> would be greatly appreciated! Thanks!
>
> Best,
>
> -Auri
>
> tell application "Microsoft Entourage"
>
> display dialog "Done with part 1" with icon 1
>
> -- get the message we're working on into a variable
> set currentMessage to the draft window
>
> -- if there is no message to duplicate, warn the user and then quit
> if currentMessage is {} then
> display dialog "Sorry, there is no message for me to duplicate. Waah!"
> with icon 1
> return
> end if
>
> -- grab the data from the message draft window
> set theSubject to (subject of currentMessage)
> set theCategory to (category of currentMessage)
> set theContent to (content of currentMessage)
>
> -- create a new message with the information from the current message
> set newMessage to make new message with properties {subject:theName,
> category:theCategory, content:theContent}
>
> -- open the new message we just created
> open newMessage
>
> end tell
--B_3167415734_2928848
Content-type: text/html;
charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable
<HTML>
<HEAD>
<TITLE>Re: Access Message Draft Window in Applescript</TITLE>
</HEAD>
<BODY>
<FONT FACE=3D"Verdana, Helvetica, Arial"><SPAN STYLE=3D'font-size:12.0px'><BR>
set currentMessage to the draft window<BR>
<BR>
doesn't make any sense. You have to specify _which_ window. And if there is=
n't one it wouldn't be an empty list {}, it would simply error. Later =
on, there's another error with categories - draft windows don't have a categ=
ory property so you can't get the category "specs". Then you have =
another error where you try to use the variable 'theName' which is undefined=
, at least in the part of the script you sent. Then there's another error in=
that you can't make a 'new message': it has to be a new 'outgoing message'.=
(Assuming that you don't simply want to make a new draft window.)<BR>
<BR>
This will work:<BR>
<BR>
tell application "Microsoft Entourage"<BR>
<BR>
display dialog "Done with part 1" with ic=
on 1<BR>
<BR>
-- get the message we're working on into a variable=
<BR>
set currentMessage to window 1<BR>
<BR>
-- if there is no message to duplicate, warn the us=
er and then quit<BR>
if class of currentMessage ≠ draft window the=
n<BR>
display dialog "Sorry,=
there is no message for me to duplicate. Waah!" with icon 1<BR>
return<BR>
end if<BR>
<BR>
-- grab the data from the message draft window &nbs=
p; <BR>
set theSubject to (subject of currentMessage)<BR>
set theContent to (content of currentMessage)<BR>
<BR>
-- create a new message with the information from t=
he current message<BR>
set newMessage to make new outgoing message with pr=
operties {subject:theSubject, content:theContent} <BR>
<BR>
-- open the new message we just created<BR>
open newMessage<BR>
<BR>
end tell<BR>
<BR>
<BR>
-----------------------<BR>
<BR>
Here's a version that will include the category. You have to save the draft=
window. then get the 'displayed message' of that window.<BR>
<BR>
<BR>
<FONT COLOR=3D"#0000FF"><B>tell</B></FONT> <FONT COLOR=3D"#0000FF">application<=
/FONT> "Microsoft Entourage"<BR>
<BR>
<FONT COLOR=3D"#0000FF">display dialog</FONT> "D=
one with part 1" <FONT COLOR=3D"#0000FF">with icon</FONT> 1<BR>
<BR>
--<FONT COLOR=3D"#4C4D4D"><I> get the message we're w=
orking on into a variable<BR>
</I></FONT> <FONT COLOR=3D"#0000FF"><B>set</B></FONT> <FONT=
COLOR=3D"#408000">frontWindow</FONT> <FONT COLOR=3D"#0000FF"><B>to</B></FONT> <=
FONT COLOR=3D"#0000FF">window</FONT> 1<BR>
<BR>
--<FONT COLOR=3D"#4C4D4D"><I> if there is no message =
to duplicate, warn the user and then quit<BR>
</I></FONT> <FONT COLOR=3D"#0000FF"><B>if</B></FONT> <FONT =
COLOR=3D"#0000FF">class</FONT> <FONT COLOR=3D"#0000FF"><B>of</B></FONT> <FONT CO=
LOR=3D"#408000">frontWindow</FONT> ≠ <FONT COLOR=3D"#0000FF">draft window<=
/FONT> <FONT COLOR=3D"#0000FF"><B>then<BR>
</B></FONT> <FONT COLOR=3D"#0000FF"=
>display dialog</FONT> "Sorry, there is no message window for me to dup=
licate. Waah!" <FONT COLOR=3D"#0000FF">with icon</FONT> 1<BR>
<FONT COLOR=3D"#0000FF"><B>re=
turn<BR>
</B></FONT> <FONT COLOR=3D"#0000FF"><B>end</B></FONT> <FONT=
COLOR=3D"#0000FF"><B>if<BR>
</B></FONT> <BR>
<FONT COLOR=3D"#0000FF">save</FONT> <FONT COLOR=3D"#408=
000">frontWindow<BR>
</FONT> <BR>
<FONT COLOR=3D"#0000FF"><B>set</B></FONT> <FONT COLOR=
=3D"#408000">currentMessage</FONT> <FONT COLOR=3D"#0000FF"><B>to</B></FONT> <FON=
T COLOR=3D"#0000FF">displayed message</FONT> <FONT COLOR=3D"#0000FF"><B>of</B></=
FONT> <FONT COLOR=3D"#408000">frontWindow<BR>
</FONT> <BR>
--<FONT COLOR=3D"#4C4D4D"><I> grab the data from the =
message draft window <BR>
</I></FONT> <FONT COLOR=3D"#0000FF"><B>set</B></FONT> <FONT=
COLOR=3D"#408000">theSubject</FONT> <FONT COLOR=3D"#0000FF"><B>to</B></FONT> (<=
FONT COLOR=3D"#0000FF">subject</FONT> <FONT COLOR=3D"#0000FF"><B>of</B></FONT> <=
FONT COLOR=3D"#408000">currentMessage</FONT>)<BR>
<FONT COLOR=3D"#0000FF"><B>set</B></FONT> <FONT COLOR=
=3D"#408000">theCategory</FONT> <FONT COLOR=3D"#0000FF"><B>to</B></FONT> (<FONT =
COLOR=3D"#0000FF">category</FONT> <FONT COLOR=3D"#0000FF"><B>of</B></FONT> <FONT=
COLOR=3D"#408000">currentMessage</FONT>)<BR>
<FONT COLOR=3D"#0000FF"><B>set</B></FONT> <FONT COLOR=
=3D"#408000">theContent</FONT> <FONT COLOR=3D"#0000FF"><B>to</B></FONT> (<FONT C=
OLOR=3D"#0000FF">content</FONT> <FONT COLOR=3D"#0000FF"><B>of</B></FONT> <FONT C=
OLOR=3D"#408000">currentMessage</FONT>)<BR>
<BR>
--<FONT COLOR=3D"#4C4D4D"><I> create a new message wi=
th the information from the current message<BR>
</I></FONT> <FONT COLOR=3D"#0000FF"><B>set</B></FONT> <FONT=
COLOR=3D"#408000">newMessage</FONT> <FONT COLOR=3D"#0000FF"><B>to</B></FONT> <F=
ONT COLOR=3D"#0000FF">make</FONT> <FONT COLOR=3D"#0000FF">new</FONT> <FONT COLOR=
=3D"#0000FF">outgoing message</FONT> <FONT COLOR=3D"#0000FF">with properties</FO=
NT> {<FONT COLOR=3D"#0000FF">subject</FONT>:<FONT COLOR=3D"#408000">theSubject</=
FONT>, <FONT COLOR=3D"#0000FF">content</FONT>:<FONT COLOR=3D"#408000">theContent=
</FONT>, <FONT COLOR=3D"#0000FF">category</FONT>:<FONT COLOR=3D"#408000">theCate=
gory</FONT>}<BR>
<BR>
--<FONT COLOR=3D"#4C4D4D"><I> open the new message we=
just created<BR>
</I></FONT> <FONT COLOR=3D"#0000FF">open</FONT> <FONT COLOR=
=3D"#408000">newMessage<BR>
</FONT> <BR>
<FONT COLOR=3D"#0000FF"><B>end</B></FONT> <FONT COLOR=3D"#0000FF"><B>tell<BR>
</B></FONT><BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
-- <BR>
Paul Berkowitz<BR>
MVP Entourage<BR>
Entourage FAQ Page: <a href=3D"
http://www.entourage.mvps.org/toc.html"><ht=
tp://www.entourage.mvps.org/toc.html></a><BR>
AppleScripts for Entourage: <a href=3D"
http://macscripter.net/scriptbuilders/=
"><
http://macscripter.net/scriptbuilders/></a> <BR>
<BR>
Please "Reply To Newsgroup" to reply to this message. Emails will=
be ignored.<BR>
<BR>
PLEASE always state which version of Entourage you are using - **2004**, X =
or 2001. It's often impossible to answer your questions otherwise.<BR>
<BR>
<BR>
<FONT COLOR=3D"#0000FF">> From: Auri Rahimzadeh <auri@rahimzadeh.com>=
;<BR>
> Newsgroups: microsoft.public.mac.office.entourage<BR>
> Date: Fri, 14 May 2004 18:26:12 -0500<BR>
> Subject: Access Message Draft Window in Applescript<BR>
> <BR>
> I want to duplicate a mail message in Applescript... so I want to be <=
BR>
> able to read the current message draft window and create a new message=
<BR>
> based on its contents using an Applescript... any ideas? Here's my <BR=
>
> (poor) code... The error I'm getting is "Can't get subject of dra=
ft <BR>
> window." and then it quits. The script *does* compile fine. Any h=
elp <BR>
> would be greatly appreciated! Thanks!<BR>
> <BR>
> Best,<BR>
> <BR>
> -Auri<BR>
> <BR>
> tell application "Microsoft Entourage"<BR>
> <BR>
> display dialog "Done with part 1" with icon 1<BR>
> <BR>
> -- get the message we're working on into a variable<BR>
> set currentMessage to the draft window<BR>
> <BR>
> -- if there is no message to duplicate, warn the user and then quit<BR=
>
> if currentMessage is {} then<BR>
> display dialog "Sorry, there is no message for me to duplicate. W=
aah!" <BR>
> with icon 1<BR>
> return<BR>
> end if<BR>
> <BR>
> -- grab the data from the message draft window <BR>
> set theSubject to (subject of currentMessage)<BR>
> set theCategory to (category of currentMessage)<BR>
> set theContent to (content of currentMessage)<BR>
> <BR>
> -- create a new message with the information from the current message<=
BR>
> set newMessage to make new message with properties {subject:theName, <=
BR>
> category:theCategory, content:theContent}<BR>
> <BR>
> -- open the new message we just created<BR>
> open newMessage<BR>
> <BR>
> end tell<BR>
</FONT></SPAN></FONT>
</BODY>
</HTML>
--B_3167415734_2928848--