Entourage script

J

Jammer Six

OK, I've cobbled together an applscript, that is supposed to take an
incoming message or incoming messages and attach them to an outgoing
message to report spam.

This is what I've come up with, but Entourage says "Entourage got an
error. Some data was the wrong type."

It composes the outgoing message correctly, and works until and unless
the <attachment:currentMessages> is included. Then it generates the
error. The list of properties is all on one line in the Script Editor,
but my newsreader insists on breaking it into two lines.

This is the script:
**********

property spamAddr : "(e-mail address removed)"

tell application "Microsoft Entourage"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:currentMessages}
end tell

**********

Any suggestions?

Thanks!
 
J

Jammer Six

€ Get the free "SpamStopper" and "SpamReporter " scripts here:

http://www.railheaddesign.com/pages/software.html

€ More on using Entourage to stop spam:

Thank you, Diane.

Neither of those scripts do what I need done.

I use a ISP level spam service called Postini, and the spam must be
reported using attachments.
 
P

Paul Berkowitz

This is the script:
**********

property spamAddr : "(e-mail address removed)"

tell application "Microsoft Entourage"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:currentMessages}
end tell

**********

Any suggestions?

Aside from Diane's news that it's been done already, if you'd like to learn
what's going wrong here, take a look at the Entourage Dictionary:

Class attachment: An attachment to a message
Plural form:
attachments
Properties:
name Unicode text [r/o] -- the name of the attachment
file type type class [r/o] -- the type of file
file creator type class [r/o] -- the creator of file
encoding no encoding/7bit encoding/8bit
encoding/binhex/base64/uuencode/AppleSingle/AppleDouble/quoted
printable/unknown encoding [r/o] -- the MIME encoding of the data
file alias [r/o] -- alias to the associated file (if there is one)
content string [r/o] -- the encoded content (if it has been encoded)
properties record -- property that allows setting a list of properties


Virtually everything is read-only aside from 'properties', which will allow
you to set the properties when you're creating an attachment. Almost all the
other properties are a "given" once the attachment has been decided (name,
file type, file creator, etc.): this stuff is mostly useful for querying
attachments you receive, not ones you send. What's left? 'content' and
'file'. Even 'content' is really just for receive attachments, although I
might play with its and see if getting the encoded source of an email
message and setting the content might just work - chances are it won't,
because of all the special extra headers attachments need.

So that leaves just 'file'. Perhaps you know how to use that one to make a
file ('alias') on your hard disk into an attachment for a message. So how do
you use it to make a _message_, not a file, into an attachment? Well, you
simply first save the message to disk as a file, then make that file into an
attachment. In fact, that's what Entourage itself has to do - that's why you
have an "Entourage Temp" folder in your Microsoft User data folder. That's
where Entourage makes temporary files it needs for making attachments out of
messages (.eml files), contacts (vCards - .vcf files) ) and calendar
invitations (.ics files) - dragged directly from some part of Entourage. So
you could use the same Entourage Temp folder - which empties itself when
Entourage quits. Personally, if I were writing a script to distribute I
would use Apple's own 'temporary items' folder for each OS X user, because
you can specify it for any language. "Entourage Temp" will have a different
name in non-English versions of Entourage, and there's no AppleScript term
for finding it. The user 'temporary items' folder is an invisible folder
that has lots of stuff, and empties when you log out or reboot or shut down.

Because you're making a file by AppleScript, you also have to replace any
colon in the attachment's name with a "-": AppleScript won't accept ":" in a
file's name. Another thing is that 'save' doesn't have a result, so you have
to "look for" the saved message after you save it.


Here's how I'd do it:

property spamAddr : "(e-mail address removed)"

set tempFolderPath to (path to temporary items as Unicode text)

tell application "Microsoft Entourage"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
set theFiles to {}
repeat with i from 1 to (count currentMessages)
set theMessage to item i of currentMessages
set theSubject to subject of theMessage
set AppleScript's text item delimiters to {":"}
set wordList to text items of theSubject
set AppleScript's text item delimiters to {"-"}
set theSubject to wordList as Unicode text

save theMessage in (tempFolderPath & theSubject) -- just the path
set theFile to alias (tempFolderPath & theSubject) --actual file
set end of theFiles to theFile
end repeat
set AppleScript's text item delimiters to {""}

make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:theFiles}

end tell




--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html

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

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 
J

Jammer Six

**********
property spamAddr : "(e-mail address removed)"

set tempFolderPath to ("Big
Phantom:Users:lyleharwood:Documents:Microsoft User Data:Entourage
Temp")

tell application "Microsoft Entourage"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
set theFiles to {}
repeat with i from 1 to (count currentMessages)
set theMessage to item i of currentMessages
set theSubject to subject of theMessage
set AppleScript's text item delimiters to {":"}
set wordList to text items of theSubject
set AppleScript's text item delimiters to {"-"}
set theSubject to wordList as Unicode text

save theMessage in (tempFolderPath & theSubject) -- just the path
set theFile to alias (tempFolderPath & theSubject) --actual file
set end of theFiles to theFile
end repeat
set AppleScript's text item delimiters to {""}

make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:theFiles}

end tell

*************

I went and got the Get Info box for the Entourage Temp folder, and
copied the path to that folder into the first line of your code,
replacing "path to temporary items as Unicode tex" with the path.

When I run the script, I get an error that says "Can't get alias "Big
Phantom:Users:lyleharwood:Documents:Microsoft User Data:Entourage
Temp:Test Message""

I suspect it's not Unicode text, but I don't know what that is. It
generates the same error with or without the quotation marks
surrounding the path.
 
P

Paul Berkowitz

I went and got the Get Info box for the Entourage Temp folder, and
copied the path to that folder into the first line of your code,
replacing "path to temporary items as Unicode tex" with the path.

When I run the script, I get an error that says "Can't get alias "Big
Phantom:Users:lyleharwood:Documents:Microsoft User Data:Entourage
Temp:Test Message""

I suspect it's not Unicode text, but I don't know what that is. It
generates the same error with or without the quotation marks
surrounding the path.

It seems that in OS 10.2.x Entourage isn't permitted by AppleScript to
compile its own alias. So you have to preface the line with 'tell me to' if
it's inside an Entourage tell block:

tell me to set theFile to alias (tempFolderPath & theSubject)

That will work.

You've also made an error with your file path - folder paths always end in a
colon:

set tempFolderPath to ("Big
Phantom:Users:lyleharwood:Documents:Microsoft User Data:Entourage Temp:")



Under some circumstances it will work anyway, but under others it won't. and
you could instead use this inside the Entourage tell block:

tell application "Microsoft Entourage"
set tempFolderPath to (path to MUD as Unicode text) & "Entourage Temp:"


--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html

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

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 
J

Jammer Six

Now, with this code, using the spam below the code, it generates a
different error.

Now it says "Microsoft Entourage got an error: Parameter Error".

I've used it on several pieces of spam, and this piece is the only one
that generates this error.

The only thing I can think of is that it uses a different character
set, although it works on Chinese spam just fine.

***********

property spamAddr : "(e-mail address removed)"

set tempFolderPath to ("Big
Phantom:Users:lyleharwood:Documents:Microsoft User Data:Entourage
Temp:")

tell application "Microsoft Entourage"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
set theFiles to {}
repeat with i from 1 to (count currentMessages)
set theMessage to item i of currentMessages
set theSubject to subject of theMessage
set AppleScript's text item delimiters to {":"}
set wordList to text items of theSubject
set AppleScript's text item delimiters to {"-"}
set theSubject to wordList as Unicode text

save theMessage in (tempFolderPath & theSubject) -- just the path
tell me to set theFile to alias (tempFolderPath & theSubject)
--actual file
set end of theFiles to theFile
end repeat
set AppleScript's text item delimiters to {""}

make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:theFiles}

end tell
***********

The spam causing the problem:

***********
Return-Path: <[email protected]>
Delivered-To: (e-mail address removed)
Received: (qmail 12795 invoked from network); 4 Oct 2003 08:52:15 -0000
Received: from exprod5mx23.postini.com (HELO psmtp.com) (12.158.34.138)
by smtp2.sea.theriver.com with SMTP; 4 Oct 2003 08:52:15 -0000
Received: from source ([216.39.128.17]) by exprod5mx23.postini.com
([12.158.34.245]) with SMTP;
Sat, 04 Oct 2003 03:52:16 CDT
Received: (qmail 9751 invoked from network); 4 Oct 2003 08:51:31 -0000
Received: from alb-24-195-205-252.nycap.rr.com (24.195.205.252)
by smtp2.sea.theriver.com with SMTP; 4 Oct 2003 08:51:31 -0000
Received: from hypercope.de [49.97.236.146] by
alb-24-195-205-252.nycap.rr.com (Postfix) with ESMTP id 6885C49CEAFD
for <[email protected]>; Sat, 04 Oct 2003 20:55:24 +0000
Date: Sat, 04 Oct 2003 20:55:24 +0000
From: (e-mail address removed)
Subject: ²ÌËÍýθÌÓ ӓ•ýÌË—ÂÌÌÓ ԕ”ÎÓÊÂÌË ÓÚ”ÓžÌÛÚ¸ ’ »ÒÔýÌËË ”Î
—ýÒÚÌšž ÎË– Ë ÚÛ•ÙË•Ï!
To: Jammer <[email protected]>
References: <[email protected]>
In-Reply-To: <[email protected]>
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/html; charset=Windows-1251
Content-Transfer-Encoding: 8bit
X-pstn-levels: (S:13.4085 R:95.9108 P:95.9108 M:99.5542 C:78.1961 )
X-pstn-settings: 5 (2.0000:8.0000) r p m C
X-pstn-addresses: from <[email protected]>
[1234/54]


ìÌËÍýθÌÓ ӓ•ýÌË—ÂÌÌÓ ԕ”ÎÓÊÂÌË ÓÚ”ÓžÌÛÚ¸ ’ àÒÔýÌËË ”Îþ —ýÒÚÌšž ÎË–
Ë ÚÛ•ÙË•Ï!
 
ÓÒÚ•Ó’ íÖçÖêàîÖ
ëÔ–ËýÎ¸ÌšÈ ’šÎÂÚ 1 ÌÓþ·•þ Ìý 10 ”ÌÂÈ/9 ÌÓ—ÂÈ
 
èÖêÖãÖí èêüåõå êÖâëéå ý/Í «LTE» çÄ ëÄåéãÖíÖ BOEING-757 ËÁ ÄùêéèéêíÄ
òÖêÖåÖíúÖÇé
 
íÛ”ý 01.11. 2003 “Ó”ý
åÓÒÍ’ý - 14:00
íÂÌ•ËÙÂ18:00

 
LTE 405

 
 
é·•ýÚÌÓ 10.11.2003 “Ó”ý
íÂÌ•ËÙÂ09:00-
åÓÒÍ’ý18:25
LTE 404
 
 
 
 
èãÄâü  ÑÖ ãÄë ÄåÖêàäÄë (œ“ ÓÒÚ•Ó’ý)
 
ÉÓÒÚËÌË–ý
ÍýÚ“ӕËþ
ÔËÚýÌËÂ
ÒÚÓËÏÓÒÚ¸
 
ORO NEGRO
 
***
 
 
HB
 
1096
 
 
FB
1150
 
FAÑABE COSTA SUR
 
****
 
HB
 
1167
 
 
FB
1229
 
 
 
 
ESMERALDA PLAYA
****
HB
1178
 
 
FB
1270
 
TROYA
 
****
 
HB
 
1193
 
TENERIFE PRINCESS
 
****
 
HB
 
1208
 
 
FB
1270
 
LAS PALMARAS
 
****
 
HB
 
1219
 
 
FB
1343
 
SOL TENERIFE
****
HB
1224
 
GRAN TENERIFE
****
HB
1255
 
 
FB
1379
 
CONQSTADOR
****
HB
1265
 
 
FB
1389
 
COSTA ADEJE PALAS
 
****
 
HB
 
1306
 
 
FB
1430
 
MELIA JARDENES DEL TEIDE
 
****
 
AL
 
1456
 
JARDIN TROPICAL
 
****
 
BB
 
1590
 
 
HB
1776
 
 
FB
1869
 
BAHIA PRINCIPE COSTA ADEJE
 
****SUP
 
AL
 
1415
 
MEDITERRANEAN PALACE
 
*****
 
BB
 
1302
 
 
HB
1426
 
 
FB
1550
 
COSTA ADEJE GRAN HOTEL
*****
BB
1210
 
 
HB
1323
 
 
FB
1437
 
 
 
 
MARE NOSTRUM
*****
BB
1395
 
 
HB
1632
 
 
FB
1849
 
 
 
 
JARDINES  DE NIVARIA
*****
BB
1643
 
 
HB
1901
 
 
FB
2005
 
 
 
 
SIR ANTHONY
*****
BB
1746
 
 
HB
2066
 
 
FB
2344
 
 
 
 
BAHIA DEL DUQUE
*****GL
BB
2283
 
 
HB
2522
 
èìùêíé ÑÖ ãÄ äêìë (Ò’• ÓÒÚ•Ó’ý)
 
ACUARIO
 
**
 
HB
 
898
 
 
FB
918
 
TROVADOR EDEN
 
***
 
BB
 
985
 
 
HB
1048
 
NOELIA PLAYA
 
AP***
 
BB
 
991
 
 
HB
1022
 
 
FB
1053
 
PUERTO PALACE
 
****
 
HB
 
1064
 
 
FB
1126
 
FLORIDA
 
****
 
HB
 
1105
 
 
FB
1157
 
LAS VEGAS
 
****
 
HB
 
1136
 
 
FB
1189
 
TENERIFE PLAYA
 
****
 
HB
 
1172
 
 
FB
1296
 
SEMIRAMIS
 
*****
 
BB
 
1220
 
 
HB
1302
 
 
FB
1406
 
PUNTA DEL REY
 
****
 
HB
 
987
 
 
FB
1038
 
 
AL
1100
BB ­ Áý’Ú•ýÍ;  HB‹ÔÓÎÛÔýÌÒËÓÌ;  FÇ‹ÔÓÎÌšÈ ÔýÌÒËÓÌ;   AL‹«’Ò ’ÍÎœ—ÂÌÓ»
 
 
ëÍË”ÍË 3-ÏÛ ’ ÌÓÏ•Â:
ÑÂÚË ÓÚ 2”Ó 8 ÎÂÚ ­ 50 %
ÑÂÚË ÓÚ 9”Ó 12 ÎÂÚ ­ 25%
ÑÂÚþÏ ÓÚ 12 ÎÂÚ Ë ’Á•ÓÒÎÓÏÛ ­ 10%.
 
 
ÇçàåÄçàÖ! éÙÓ•ÏÎÂÌË ’ËÁš ’ àÒÔýÌËœ ’ ÒÚÓËÏÓÒÚ¸ ÚÛ•ý Ì ’ÍÎœ—ÂÌý.
ÑÓÔÎýÚý Áý ’ËÁÛ ­ 45 Â’•Ó Áý ÔýÒÔÓ•Ú.
 
ñÂÌš ÛÍýÁýÌš ’ ÖÇêé Ìý 1 —ÂÎ. Ô•Ë •ýÁϘÂÌËË ’ ÒÚýÌ”ý•ÚÌÓÏ  ”’ÛžÏÂÒÚÌÓÏ
ÌÓÏÂ•Â Ë ’ÍÎœ—ýœÚ ’ Ò·þ:
-- ý’ËýÔ•ÂÎÂÚ ÚÛ”ý Ë Ó·•ýÚÌÓ;
-- •ýÁϘÂÌË ’ “ÓÒÚËÌË–Â Ò ’š·•ýÌÌšÏ •ÂÊËÏÓÏ ÔËÚýÌËþ;
-- ÒÚ•ýžÓ’ÍÛ Ìý ’•ÂÏþ ԕ·š’ýÌËþ ’ àÒÔýÌËË;
-- Ú•ýÌÒÙÂ•Ú ý›•ÓÔÓ•Ú-“ÓÒÚËÌË–ý- ý›•ÓÔÓ•Ú;
-- ÛÒÎÛ“Ë •ÛÒÒÍÓ“Ó’Ó•þ˜Â“Ó “Ë”ý.
 
íýÍ Ê ÏÓÊÂÏ Ô•Â”ÎÓÊËÚ¸ ÒΔۜ˜Ë ÌýÔ•ý’ÎÂÌËþ:
 
àÒÔýÌËþ ­ É•ýÌ äýÌý•Ëþ, ãýÌÒý•ÓÚÂ, îÛ›•ÚÂ’ÂÌÚÛ•ý, åýÈÓ•Íý, à·Ë–ý,
åÂÌÓ•Íý, äÓÒÚý Å•ý’ý, äÓÒÚý ÑÓ•ý”ý, äÓÒÚý ÅÎýÌÍý, äÓÒÚý ”Âθ ëÓθ.
 
ÑÓÏËÌËÍýÌÒÍýþ •ÂÒÔÛ·ÎËÍý, åÂÍÒËÍý, äÛ·ý, ëòÄ, äýÌý”ý.
 
ÚÂÎ.  (095) 925 5971

***********
 
P

Paul Berkowitz

Now, with this code, using the spam below the code, it generates a
different error.

Now it says "Microsoft Entourage got an error: Parameter Error".

I've used it on several pieces of spam, and this piece is the only one
that generates this error.

The only thing I can think of is that it uses a different character
set, although it works on Chinese spam just fine.


If you run it from Script Editor when that message is selected in Entourage,
which line in the script and which word(s) in the line are highlighted in
Script Editor when it errors?

--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html

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

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 
P

Paul Berkowitz

Now, with this code, using the spam below the code, it generates a
different error.

Now it says "Microsoft Entourage got an error: Parameter Error".

I've used it on several pieces of spam, and this piece is the only one
that generates this error.

The only thing I can think of is that it uses a different character
set, although it works on Chinese spam just fine.


The problem is actually likely your first line. Change it to

set tempFolderPath to ("Big
Phantom:Users:lyleharwood:Documents:Microsoft User Data:Entourage
Temp:") as Unicode text


By setting it as ordinary string (text), then when you concatenate a
non-ASCII subject to the path as the new file's name, there must be an
illegal character in the file name. If the first part of the path is Unicode
(which doesn't look any different for ASCII names such as your disk and
folder names) then when you concatenate the subject to the path the whole
thing will be in legal Unicode. As long as you're in c OS 10.1.5 or later.


My guess is that part of the culprit might also be:

set theSubject to subject of theMessage

even if it's a later line referring to the subject. Change that line to

set theSubject to subject of theMessage as Unicode text


and make sure you're using whiechever OS 10.2.x came with AppleScript 1.9.1
(I think that's OS 10.2.4 but I forget.) [Otherwise you might have to
throw a few more Unicode texts around like this:

set theSubject to subject of theMessage as Unicode text
set AppleScript's text item delimiters to {":" as Unicode text}
set wordList to text items of theSubject
set AppleScript's text item delimiters to {"-" as Unicode text}
set theSubject to wordList as Unicode text
]

I don't think you'll need the last few lines. Changing the path and the
subject to Unicode should do the trick.

--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html

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

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 
J

Jammer Six

€ > Now, with this code, using the spam below the code, it generates a
€ > different error.
€ >
€ > Now it says "Microsoft Entourage got an error: Parameter Error".
€ >
€ > I've used it on several pieces of spam, and this piece is the only one
€ > that generates this error.
€ >
€ > The only thing I can think of is that it uses a different character
€ > set, although it works on Chinese spam just fine.


€ If you run it from Script Editor when that message is selected in Entourage,
€ which line in the script and which word(s) in the line are highlighted in
€ Script Editor when it errors?

I deleted that piece of spam. Not to worry, I get more than two hundred
pieces of spam a day, and I'll get it again, or one just like it.

Now I have a new piece, that generates an error that says "File {Path
Name, ending in giberish that is the subject of the piece of spam}
wasn't found"

There's question marks, dashes, and all kinds of things in the subject
of the spam, and you mentioned something about that.

This is the line of code that highlights:

tell me to set theFile to alias (tempFolderPath & theSubject) --actual
file
 
P

Paul Berkowitz

Now I have a new piece, that generates an error that says "File {Path
Name, ending in giberish that is the subject of the piece of spam}
wasn't found"

There's question marks, dashes, and all kinds of things in the subject
of the spam, and you mentioned something about that.

This is the line of code that highlights:

tell me to set theFile to alias (tempFolderPath & theSubject) --actual
file


Just add all the Unicode stuff from my last message, and update to OS 10.2.6
or 10.2.8 if you haven't yet.


--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html

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

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 
J

Jammer Six

OK, here's where my copy of the script stands:

**********

property spamAddr : "(e-mail address removed)"

tell application "Microsoft Entourage"
set tempFolderPath to (path to MUD as Unicode text) & "Entourage
Temp:"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
set theFiles to {}
repeat with i from 1 to (count currentMessages)
set theMessage to item i of currentMessages
set theSubject to subject of theMessage as Unicode text
set AppleScript's text item delimiters to {":" as Unicode text}
set wordList to text items of theSubject
set AppleScript's text item delimiters to {"-" as Unicode text}
set theSubject to wordList as Unicode text

save theMessage in (tempFolderPath & theSubject) -- just the path
set theFile to alias (tempFolderPath & theSubject) --actual file
set end of theFiles to theFile
end repeat
set AppleScript's text item delimiters to {""}

make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:theFiles}

end tell

**********

I now have three current pieces of spam, written in two foreign
languages, that generate the error: "Can't get alias {path to temp
file}".

When I run the script from the Script Editor, it stops on this line:

set theFile to alias (tempFolderPath & theSubject) --actual file

I'm running 10.2.6, with Script Editor 1.9.
 
J

Jammer Six

€ I now have three current pieces of spam, written in two foreign
€ languages, that generate the error: "Can't get alias {path to temp
€ file}".

€ When I run the script from the Script Editor, it stops on this line:

€ set theFile to alias (tempFolderPath & theSubject) --actual file

€ I'm running 10.2.6, with Script Editor 1.9.

I just ran the script on a message written in English, and it doesn't
work at all, now.

It stops on that line in all cases, on every attempt, regardless of the
message chosen to run on.
 
J

Jammer Six

€ In article <[email protected]>, Jammer Six

€ € I now have three current pieces of spam, written in two foreign
€ € languages, that generate the error: "Can't get alias {path to temp
€ € file}".
€ €
€ € When I run the script from the Script Editor, it stops on this line:
€ €
€ € set theFile to alias (tempFolderPath & theSubject) --actual file
€ €
€ € I'm running 10.2.6, with Script Editor 1.9.

€ I just ran the script on a message written in English, and it doesn't
€ work at all, now.

€ It stops on that line in all cases, on every attempt, regardless of the
€ message chosen to run on.

More information.

It isn't "regardless of the message chosen to run on."

It's only on some messages. Furthermore, it doesn't run on some
messages written in English, and it does run on some messages written
in foreign languages.

I have the messages it runs on, and I have some examples of messages it
doesn't run on isolated.

I can send them to you, or post them here. I've gone back to using my
email address for testing.

When it fails, in the Script Editor, it fails on the line "tell me to
set theFile to alias (tempFolderPath & theSubject) --actual file".

This is the code that works sometimes, and not others:


***********
property spamAddr : "(e-mail address removed)"

tell application "Microsoft Entourage"
set tempFolderPath to (path to MUD as Unicode text) & "Entourage
Temp:"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
set theFiles to {}
repeat with i from 1 to (count currentMessages)
set theMessage to item i of currentMessages
set theSubject to subject of theMessage
set AppleScript's text item delimiters to {":"}
set wordList to text items of theSubject
set AppleScript's text item delimiters to {"-"}
set theSubject to wordList as Unicode text

save theMessage in (tempFolderPath & theSubject) -- just the path
tell me to set theFile to alias (tempFolderPath & theSubject)
--actual file
set end of theFiles to theFile
end repeat
set AppleScript's text item delimiters to {""}

make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:theFiles}

end tell
***********
 
P

Paul Berkowitz

It isn't "regardless of the message chosen to run on."

It's only on some messages. Furthermore, it doesn't run on some
messages written in English, and it does run on some messages written
in foreign languages.


You never changed the subject line to:

set theSubject to subject of theMessage as Unicode text

That's essential, since the subject ends up forming part of the file path.
If it's non-Western European (actually, even if it has accents) the path
will be wrong. I suspect that even the spam messages in English have some
weird character in the subject - possibly after 20 spaces or so such that
you don't even see those characters - as some sort of way of avoiding spam
filters.

Then let's add a file extension:


save theMessage in (tempFolderPath & theSubject & ".eml") -- just the
path
tell me to set theFile to alias (tempFolderPath & theSubject & ".eml")


See if this works as is. If not, insert a line between those two:

tell application "Finder" to update alias tempFolderPath




--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html

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

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 
J

Jammer Six

€ That's essential, since the subject ends up forming part of the file path.
€ If it's non-Western European (actually, even if it has accents) the path
€ will be wrong. I suspect that even the spam messages in English have some
€ weird character in the subject - possibly after 20 spaces or so such that
€ you don't even see those characters - as some sort of way of avoiding spam
€ filters.

I suspect you're right about that. I notice that the spam that doesn't
run has the string "#0" in the subject line.

Here's the subject, copied and pasted from one piece that doesn't run:

Re- Construction Help Needed #0

Here's another one that doesn't run:

ÍøÂçºÍÐÅÏ¢»¯½¨Éèµß·å---ÃÀ¹ú³ö#0

The only thing I see is that they both have the string "#0" in them.

Here's the script with all the changes. It doesn't run at all:
**********
property spamAddr : "(e-mail address removed)"

tell application "Microsoft Entourage"
set tempFolderPath to (path to MUD as Unicode text) & "Entourage
Temp:"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
set theFiles to {}
repeat with i from 1 to (count currentMessages)
set theMessage to item i of currentMessages
set theSubject to subject of theMessage as Unicode text
set AppleScript's text item delimiters to {":"}
set wordList to text items of theSubject
set AppleScript's text item delimiters to {"-"}
set theSubject to wordList as Unicode text

save theMessage in (tempFolderPath & theSubject & ".eml") -- just
the path
tell application "Finder" to update alias tempFolderPath
tell me to set theFile to alias (tempFolderPath & theSubject &
".eml") --actual file
set end of theFiles to theFile
end repeat
set AppleScript's text item delimiters to {""}

make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:theFiles}

end tell
**********

This script runs, but not on certain messages:

**********
property spamAddr : "(e-mail address removed)"

tell application "Microsoft Entourage"
set tempFolderPath to (path to MUD as Unicode text) & "Entourage
Temp:"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
set theFiles to {}
repeat with i from 1 to (count currentMessages)
set theMessage to item i of currentMessages
set theSubject to subject of theMessage --as Unicode text
set AppleScript's text item delimiters to {":"}
set wordList to text items of theSubject
set AppleScript's text item delimiters to {"-"}
set theSubject to wordList as Unicode text

save theMessage in (tempFolderPath & theSubject) -- just the path
--tell application "Finder" to update alias tempFolderPath
tell me to set theFile to alias (tempFolderPath & theSubject)
--actual file
set end of theFiles to theFile
end repeat
set AppleScript's text item delimiters to {""}

make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:theFiles}

end tell

**********
 
P

Paul Berkowitz

I suspect you're right about that. I notice that the spam that doesn't
run has the string "#0" in the subject line.

Here's the subject, copied and pasted from one piece that doesn't run:

Re- Construction Help Needed #0

Here's another one that doesn't run:

ÃøÂçºÃÃÅ⻯½¨Éèµß·å---ÃÀ¹ú³ö#0

The only thing I see is that they both have the string "#0" in them.

Here's the script with all the changes. It doesn't run at all:

The "#0" isn't really "#0" - that's a display "placeholder" for some
character(s) that can't be displayed.

Personally, I don't like introducing the Finder when not absolutely required
- that may be creating a problem. I really would put back 'as Unicode text'
into this line:

set theSubject to subject of theMessage as Unicode text

You do need that - really.

I have read in a certain Release Note that there are bugs with 'alias' in
AppleScript 1.9 and 1.9.1 and certain (undisclosed) file paths. So maybe
you're hitting that problem. Entourage's 'file' property for 'attachment'
does require the alias form, so there's no way around that. Try again in
Panther - it shouldn't be too long a wait now.



--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html

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

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 
J

Jammer Six

€ Personally, I don't like introducing the Finder when not absolutely required
€ - that may be creating a problem. I really would put back 'as Unicode text'
€ into this line:

€ set theSubject to subject of theMessage as Unicode text

€ You do need that - really.

Well, I have two messages saved that the script worked on, and with
that addition, those two messages fail, saying that the alias couldn't
be found.

It looks to me like it's going to fail, on one type of message or
other, and with the "as Unicode text" commented out, it seems to work
on more messages than when it's in.
 
J

Jammer Six

€ I have read in a certain Release Note that there are bugs with 'alias' in
€ AppleScript 1.9 and 1.9.1 and certain (undisclosed) file paths. So maybe
€ you're hitting that problem. Entourage's 'file' property for 'attachment'
€ does require the alias form, so there's no way around that. Try again in
€ Panther - it shouldn't be too long a wait now.

Are there any debugging apps available for Applescript?

It surprises me that this can't be done.
 
P

Paul Berkowitz

€ I have read in a certain Release Note that there are bugs with 'alias' in
€ AppleScript 1.9 and 1.9.1 and certain (undisclosed) file paths. So maybe
€ you're hitting that problem. Entourage's 'file' property for 'attachment'
€ does require the alias form, so there's no way around that. Try again in
€ Panther - it shouldn't be too long a wait now.

Are there any debugging apps available for Applescript?

It surprises me that this can't be done.

What do you mean? The bug must have to do with certain file path Unicode
characters or something like that. What is there to debug? You know where
the bug is, and you can't fix bugs in AppleScript, only Apple can, and they
have fixed it for the version of AppleScripting that will ship with Panther.

Since it doesn't really matter in your case - does it? - to get the subject
100% correct _as the name of the attachment_ : it will be correct in the
headers, why don't you just truncate it and adapt it something like this:


set theSubject to subject of theMessage as string
if (count theSubject) > 29 then set theSubject to text 1 thru 28 of
theSubject & "Š"

(hat dieresis is only one character if you make it by typing option-; Since
your own disk and folder names are orthodox, this may help. But even 'as
string' is not plain text, it's "international string" so it may possibly
still, have the same problems, although I doubt it, If it does, you can
definitely get rid of all "funny characters" like this:


set theSubject to subject of theMessage
set theSubject to AsText(theSubject) -- see below
--if (count theSubject) > 29 then set theSubject to text 1 thru 28 of
theSubject & "Š"

Then include this handler in the script:



on AsText(str)
--coerce Unicode or other text to styled string to plain text
try
return (((str as string) as record)'s «class ktxt»)
end try
return str -- if plain text to begin with

end AsText



This will work around your problem. You still have to keep in the
substitution of "-" for ":" as well, of course.

--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html

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

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top