-- ---------------------------------------------------------------------------------------- -- This script takes the Finder folder that is choosen and imports all files that are -- Outlook Express message files into Microsoft Entourage 2001. It creates the same folder -- structure as the Finder's in Entourage under the top folder name of "Imported Folders". -- This script is basically Steve Friesen's (steve@skyweyr.com) Archive Messages script -- called "Import Indiv. Msg Archive". It was slightly modified by Bill Wright -- (bwright_us@mac.com) to relax the check requiring both file type and creator type -- to be from Outlook Express in order for the file to be imported. Instead, it takes -- all files whose filename ends with ".EML". This small change is necessary to read -- message files from the PC version of OE. This script is the final step in the method -- of importing email messages into OE 5 or Entourage on the Mac from email messages -- exported from Outlook Express 5.5 on Windows. It can also be used to import message -- files exported using OEexporter (or OEexporter4Entourage). (3/2001) -- ---------------------------------------------------------------------------------------- set log_ref_num to -1 global log_ref_num set logging to false global logging try set logginganswer to button returned of (display dialog ("Do you wish to turn on Logging?") buttons {"Logging", "No Logging"} default button {"No Logging"}) if logginganswer is equal to "Logging" then set logging to true if logging then tell application "Finder" set OE_path to file of process "Microsoft Entourage" as string set OE_folder to (container of file OE_path) as string end tell set log_filename to "OEimporter" & shortDate() & ".log" set log_ref_num to create_and_clear_file(OE_folder & log_filename) save_data_to_file("Log Created on " & (date string of (current date)) & " at " & (time string of (current date)) & return) end if set theFoldertoImport to (choose folder with prompt "Choose the folder which will be imported.") tell application "Microsoft Entourage" activate if folder "Imported Folders" exists then set mainimportfolder to folder "Imported Folders" else set mainimportfolder to make new folder with properties {name:"Imported Folders"} end if end tell ImporttheMessages(theFoldertoImport, mainimportfolder) activate display dialog ("\"" & (theFoldertoImport as string) & "\" has been Imported to the OE folder \"Imported Folders\"") buttons {"OK"} default button {"OK"} giving up after 30 if logging then display dialog ("The import log can be found at \"" & OE_folder & "\"") buttons {"OK"} default button {"OK"} giving up after 30 on error error_msg number error_num try if log_ref_num is not equal to -1 then my close_the_file() on error end try if error_num is not equal to -128 then error (error_msg as string) & (error_num as string) end if end try --This routine imports all of the OE message files of the Finder folder --and puts them into the OE folder that is passed into it. It is recursive --so it handles children folders. on ImporttheMessages(theFinderFolder, theOEParentFolder) tell application "Finder" set theOEFolder to name of theFinderFolder end tell tell application "Microsoft Entourage" set OEfolderRef to make new folder with properties {parent:theOEParentFolder, name:theOEFolder} if logging then my save_data_to_file(return & "Importing messages for Entourage folder \"" & theOEFolder & "\"" & return) end tell tell application "Finder" set thefiles to every file in theFinderFolder set thesubfolders to every folder in folder theFinderFolder end tell repeat with i in thefiles -- 9.2.2 bug: set theFileInfo to info for i if logging then set thefilename to name of i my save_data_to_file("Importing file \"" & thefilename & "\" from Finder folder \"" & (theFinderFolder) & "\"" & return) end if -- 9.2.2 bug: if visible of theFileInfo then -- -- 9.2.2 bug: if (name of theFileInfo ends with ".EML") then -- replacement line due to 9.2.2 bug: if (name of i ends with ".EML") then tell application "Microsoft Entourage" make new incoming message with properties {storage:OEfolderRef, source:(alias (i as string)), read status:read} end tell end if -- 9.2.2 bug: end if end repeat repeat with thefolder in thesubfolders ImporttheMessages((thefolder as alias), OEfolderRef) end repeat end ImporttheMessages --This handler creates and clears a file and gets the file ready for writing. --The argument "file_path" is the path to the file to be created and cleared. --This handler returns an integer that can be used to reference the file in subsequent commands. on create_and_clear_file(file_path) set file_ref_num to (open for access file file_path with write permission) set eof file_ref_num to 0 return file_ref_num end create_and_clear_file --This handler writes information to a file. --The argument "file_ref_num" is a reference to the file to be written to. --The argument "the_data" is the information that will be written to the file. --This handler does not return anything. on save_data_to_file(the_data) write the_data to log_ref_num end save_data_to_file --This handler closes a file. --The argument "file_ref_num" is a reference to the file to be closed. --This handler does not return anything. on close_the_file() close access log_ref_num end close_the_file --This handler converts the current date and time into a short --form with characters legal to use in a filename. on shortDate() set today to current date set thisDate to day of today -- Get the "day" set theDay to thisDate + 0 -- Get the "month" set theMonth to month of today as string set theMonth to characters 1 through 3 of theMonth -- Get the "year" set thisYear to year of today set theYear to thisYear + 0 set theYear to characters 3 through 4 of (theYear as string) as string -- Get the "hour" set timeStr to time string of today set Pos to offset of ":" in timeStr set theHour to characters 1 thru (Pos - 1) of timeStr as string set timeStr to characters (Pos + 1) through end of timeStr as string -- Get the "minute" set Pos to offset of ":" in timeStr set theMin to characters 1 thru (Pos - 1) of timeStr as string set timeStr to characters (Pos + 1) through end of timeStr as string --Get "AM or PM" set Pos to offset of " " in timeStr set theSfx to characters (Pos + 1) through end of timeStr as string return (theDay & theMonth & theYear & " _" & theHour & "." & theMin & theSfx) as string end shortDate