problem with script

For some reason, this script, “Import selected Entourage messages,” keeps asking for DEVONthink and not DEVONthink Pro. It only works when I select the PE version of DT, even though the description states:

“Imports all currently selected messages of Entourage as plain text. Copy the script to the folder “~/Documents/Microsoft User Data/ Entourage Script Menu Items”. Afterwards it’s possible to select this script from the Entourage Script Menu to import the currently selected messages (DEVONthink Pro is automatically launched).”

I looked at the script in Script Editor, and it does specify DT Pro. But something in the script keeps it asking for the older version of DT and I don’t know what it is. Can anyone help? Here’s the script:

Any suggestions would be most welcome!

Alexandria

I’m having trouble with this script too. I get an error message pointing to the following line:

tell application “DEVONthink Pro” to «event imptimpt» theFile

It doesn’t recognize “imptimpt”. Might that be “import”?

Try this
Make a new script with this code in Entourage’s script menu
Select the messages to move to DT Pro
Run Script from the Entourage Menu

property pNoSubjectString : “(no subject)”
tell application “Microsoft Entourage”
try
set theSelection to the selection
if the length of theSelection is less than 1 then
display dialog “One or more messages must be selected.” buttons {“OK”} default button 1 with icon caution
else
repeat with theMessage in theSelection
set theSubject to subject of theMessage
set theSender to (address of sender of theMessage) as string
set theHeaders to headers of theMessage
set theContent to content of theMessage
set theDate to time received of theMessage
if theSubject is equal to “” then set theSubject to pNoSubjectString

			tell application "DEVONthink Pro"
				
				create record with {name:theSubject, type:txt, date:theDate, URL:theSender, plain text:return & (theContent as string)} in database 1
				
			end tell
		end repeat
		
		
	end if
	
end try

end tell

Mike:
Thanks for the script – it works great. However, how about some frosting on the cake?

I normally save a message as text, which gives me the To, From, Date/Time, Subject, which is important to me. (Don’t need the full Header or Source). Is there any way to add that to the script?

I used to use an Entourage script “Many to Word”, which compiled several messages into one Word document – a great way to save a series of exchanges about a single topic, or during a certain period of time.

I see that DT Pro has a “Merge” function, which I can use for this once I have imported the messages, but I sure would like to have them ID’d first.

The script I use has some frosting also, I only sent part of it as a start.

If I understand, you’d like several Ent messages to go to one DT Pro text entry.

Example—
Message 1
To
From
Date
Subject
Body
Message 2
To
From
Date
Subject
Body
MSG 3 and so on ----all as on DT Pro entry
With or Without labels ?
If you’d like, give me a little more info and I’ll work on it later tonight or tomorrow morning
Doesn’t seem to be too hard
Have to go to a baseball game now but I’ll be glad to help

Mike

Mike,

Thanks for the script! On my part, I’d like the messages to be separate if possible, so I can see them by entry inside a folder. With the same info you mentioned in your message–from info, date sent, subject, message.

Also, how do you tell DT Pro to put it into a specific folder? I have preferences set to put new notes into a particular folder, but the imported messages aren’t going there. I see where you tell DTP to create a record. How might I tell it to create that record in my InBox folder?

Thanks for your help!! I’m going to get myself a book on applescripting and learn how to do this for myself! You can do so much with it.

Alexandria

Mike:

Thanks for your help – and I hope you enjoy the ball game!

I’d like to be able to send a single Entourage message to DTPro, or select several and send them to DTPro as separate files.

It isn’t necessary for the script to compile them into a single file because Merge will let me do that in DTPro whenever I want to.

And I second Alexwein’s question about how to get the script to import to a specific folder – can the script be written to import to the current highlighted folder? Or could it generate a query asking where to put it?

The latter would be especially helpful given that DTPro allows multiple databases – then you wouldn’t even need to prepare for the export from Entourage by having the right one open.

Not to be greedy, or anything. Obviously I need a book on scripting too; sigh, so many toys, so little time.

I use other peoples scripts
My start was from a beta of DT pro–I was a beta user
You should have a copy of my starter script with your version of Pro ??

I tried a modification of what I use and this will work as a start to both of your requests

REMEMBER PLEASE–You need a top level group named “Inbox”
And 2 or more sub-groups of “Inbox” named whatever you like

The script will show you a list of the sub-groups—choose 1 to send the Messages to
I use this and at the same time have some Entourage folders named as the DT sub groups
My script moves the mail messages to the Ent folder after import to DT

This can probably be modified to choose different databases but I only use one myself

– Import selected Entourage messages to DEVONthink Pro.
– Developed on Mac OS X 10.2.6 with DEVONthink PE 1.7.1 by Stephen D. Poole, stevep@wrq.com 2003-08-28
– Modified for Entourage by Bruce Klutcho on 12/29/03 on Mac OS 10.3.2 with DEVONthink 1.7.4 with help from David Cortright
– Modified for DEVONthink Pro by Christian Grunenberg on 12/08/04

– this string is used when the message subject is empty
property pNoSubjectString : “(no subject)”

– entry point

tell application “DEVONthink Pro”

tell database 1
	set g to (first record whose name is "Inbox")
	tell g
		try
			set f to name of (every child)
			set r to choose from list f
			
			set j to r as string
			
			
		on error
			set the result to "none"
		end try
		
		
	end tell
	
end tell

end tell
tell application “Microsoft Entourage”
try
set theSelection to the selection
if the length of theSelection is less than 1 then
display dialog “One or more messages must be selected.” buttons {“OK”} default button 1 with icon caution
else
repeat with theMessage in theSelection
set theSubject to subject of theMessage
set theSender to (address of sender of theMessage) as string
set theHeaders to headers of theMessage
set theContent to content of theMessage
set theDate to time received of theMessage
if theSubject is equal to “” then set theSubject to pNoSubjectString

			tell application "DEVONthink Pro"
				
				create record with {name:theSubject, type:txt, date:theDate, URL:theSender, plain text:return & (theContent as string)} in ¬
					(first child whose name is j) of (first record whose name is "Inbox") of database 1
				
			end tell
		end repeat
		
		
	end if
	
end try

end tell

DC and Alexandria
I quick posted this last night

Let me know if there’s any problems or need tweaks in content or usage
Also DC if you still want a merge from applescript – we can do that

Don’t be afraid to ask–These aren’t that hard and since we started I’d like to work on it until it’s usefull to both of you.
If each need a different script OK
Or maybe you look at the code and learn how to make something for yourselves later on–That would be neat too.
DT Pro is very powerfil and flexible with applescript–If you may not have all the examples with Pro try to get them
Very usefull

Your friend Mike

Hi Mike,

Thanks so much! Not just for the scripts, but for your generous nature! I actually tweaked the first script you gave us so it would send the mail to my InBox, but without the need to create subfolders. BUT, I have that one too in case I find I need it. But I was able to use the scripting in the second one to modify the first one! I like the way the first one works in the background–it sends the message(s) to DTP without leaving Entourage. Plus, I just pile everything into my inbox for later sorting, so I didn’t need the subfolders. So it works great for me!

I wonder, though, how to get the send date as part of what gets imported. I see where the script specifies to Entourage to “set theDate to time received of theMessage,” and for Pro, to set the date as ‘theDate,’ but I don’t see the send date anywhere in what gets brought over. Not sure where it would appear nor how to get it there.

So we are close! Also, is there a way to find out how particular programs are scriptable–such as how to tell Entourage what to do? What kinds of commands are possible and what they do, etc.?

Many, many thanks for your help,

Alexandria

Alexandria.

To see what each program can do --In script editor go to open dictionary in the “File Menu”

That brigs up a list of (most of) the applications that can be scripted that you have on your disck
Click one and watch.

“Time recieved” can be changed in the script you have to “time sent”
When the script runs (I think) it will do what you want.

If you need both recieved and sent let me know—otherwise you seem to be able to make the change yourself
Open the dictionary for Entourage and look for the properties of a message
You’ll see what I mean

God luck
Mike

Mike:

I want to add my thanks to Alexandria’s for doing all this. However, I haven’t been able to try any of it. I can’t get any of my new DTPro databases to open! I’m going to post a message to the forum under another topic, but if you have any ideas for what could be going on, I’d appreciate it.

Everything was fine when I shut down last night; opened up this AM and nothing. The program opens, and tries to open a db, but gets about a third of the way and quits. I tried clicking on the file instead of opening from within the program, I shut down, restarted, nothing. I downloaded Pro again, and still nothing.

DCB

DC,

I’m sorry but I have no idea.
I’m sure someone does though.
I’ll watch your other post to see how things go.
One question–any problems with other apps and files ?

I’ll even say a prayer–that helps me.

Once you’re up and running again feel free add questions if you have any.

Mike

DCB,

This may sound strange, but when you open the db, try clicking on the dock icon to see if the db is truly open. I had a problem where I’d open the db, then nothing, then I’d click on the dock icon and then it would appear.

You might have already tried this, and it may mean nothing. But I wanted to mention it.

Alexandria

Mike,

Thanks! I haven’t had a chance to try out your suggestions, but I will later today. Many, many thanks!!!

Alexandria