• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Script to Copy/Paste Entourage Message Bodies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Script to Copy/Paste Entourage Message Bodies


  • Subject: Re: Script to Copy/Paste Entourage Message Bodies
  • From: Ramona Rock <email@hidden>
  • Date: Tue, 25 Mar 2003 13:30:22 -0800

Yay! That's brilliant, and it works! Thank you! I do have a couple of
minor questions if you don't mind, but that's definitely the substance of
the thing. Since you said there were problems with option #2, I just went
with option #1.

1. Why does it send it as plain text instead of rich text? This is a very
minor thing since I know I can just change it back to rich text after it
gets there, but I had to ask.

2. The TextEdit document gets opened, accessed and receives the data as
expected. But if I make any changes to the document after that (I was just
making it rich text and a little bigger like it was originally in Entourage
so I could read it better, the text originally gets to the document smaller
and in plain text) it changes the name of the document to Untitled? What's
up with that?

on 3/25/03 11:40 AM, email@hidden at email@hidden wrote:

> On 3/24/03 5:03 PM, "Ramona Rock" <email@hidden> wrote:
>
>> Hi there. I'm a relative newbie, and I'm desperately trying to write what I
>> thought would be a fairly simple script to take the messages out of a folder
>> which I would designate by title in Entourage, copy their message bodies (I
>> don't want the subject or any other header info), paste them into a TextEdit
>> document on my desktop, then move those messages into another folder. (My
>> original plan was to paste it into an MS Word document, but after the
>> discussion earlier today re: the difficulty in scripting MS Word, I thought
>> I'd go with TextEdit instead.)
>>
>> Here is what I have so far, in part via help from Andrew on this list
>> (thanks Andrew) but I still can't get it to work. The last error I got was
>> "TextEdit got an error: document ":desktop:newstuff" doesn't understand the
>> open message."
>>
>> Could someone tell me what I'm doing wrong? I'd be most appreciative!
>> Thanks! Ramona
>>
>> tell application "TextEdit"
>> open document ":desktop:newstuff"
>> end tell
>> tell application "Microsoft Entourage"
>> repeat with aMessage in folder "New Stuff"
>> set theBody to content of aMessage
>> tell application "TextEdit"
>> write theBody to "newstuff"
>> end tell
>> move aMessage to folder "Archived"
>> end repeat
>> end tell
>
> There's not much problem with your Entourage scripting. Just one. you can't:
>
> repeat with aMessage in folder "New Stuff"
>
> You can only use 'repeat with aSomething in' a LIST, not an Entourage
> folder. First you have to
>
> set theMessages to every message in folder "New Stuff" -- a list of
> messages
>
> Then you can
>
> repeat with aMessage in theMessages
>
> The problem is with your TextEdit scripting: TextEdit does not have a
> 'write' command. It's not anywhere in its dictionary - take a look and
> you'll see. Also you should not be putting one tell block inside another
> one, but that's a minor issue. Also
>
> open document ":desktop:newstuff"
>
> does nothing. It's not a proper file path to an existing document, and
> that's why you're getting an error.
>
> 'write' is a Standard Addition that does not need any application tell
> block. Check the Standard Additions dictionary in ScriptingAdditions
> (/System/Library/ScriptingAdditions/). What it does need is an 'open for
> access file filePath with write permission' which will make a new text file
> on your disk, which you can then open in TextEdit. Or else you can try to
> script TextEdit itself with its own commands. Here are the two methods. The
> first method is better because I can't work out how to save a TextEdit doc
> in the second method. In both cases remove the email-induced carriage
> returns in the middle of long lines when pasting to Script Editor. I've
> added a separator between messages.
>
>
>
> 1. To new text file, opened in TextEdit
>
>
> set fileSpec to (path to desktop as string) & "newstuff"
> set fileRef to open for access file fileSpec with write permission -- makes
> new "newstuff" file or overwrites existing one
> set eof fileRef to 0 -- clean overwrite (erases previous text)
> --omit previous line to continue on without replacing
>
> tell application "Microsoft Entourage"
> set theMessages to every message in folder "New Stuff"
> repeat with aMessage in theMessages
> set theBody to content of aMessage as string
> tell me to write (theBody & return & "---------------" & return) to
> fileRef starting at ((get eof fileRef) + 1) -- one line
> -- must 'tell me' because fileRef is outside Entourage
> move aMessage to folder "Archived"
> end repeat
> end tell
>
> close access fileRef
>
> tell application "TextEdit"
> activate
> open {alias fileSpec} -- TextEdit needs a list!
> end tell
>
> -----------------------------------
>
> 2. To TextEdit doc, but i haven't figured out how to save a TextEdit doc to
> a file path as it should. I always get a "type 8" error and it doesn't get
> saved, although it does get named. Adding extensions and/or file types
> doesn't help.
>
> set fileSpec to (path to desktop as Unicode text) & "newstuff"
> tell application "TextEdit" to set newDoc to make new document at end of
> documents -- one line
>
> set theText to ""
> tell application "Microsoft Entourage"
> set theMessages to every message in folder "New Stuff"
> repeat with aMessage in theMessages
> set theBody to content of aMessage as string
> set theText to theText & (theBody & return & "---------------" &
> return)
> move aMessage to folder "Archived"
> end repeat
> end tell
>
> tell application "TextEdit"
> set text of newDoc to theText
> --save newDoc in fileSpec -- can't
> end tell
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Script to Copy/Paste Entourage Message Bodies
      • From: Paul Berkowitz <email@hidden>
References: 
 >Re: Script to Copy/Paste Entourage Message Bodies (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: RE: Why are compiled scripts slower than from Script Editor?
  • Next by Date: Re: Acrobat
  • Previous by thread: Re: Script to Copy/Paste Entourage Message Bodies
  • Next by thread: Re: Script to Copy/Paste Entourage Message Bodies
  • Index(es):
    • Date
    • Thread