Combination
Combination
- Subject: Combination
- From: Bernard Azancot <email@hidden>
- Date: Fri, 28 Sep 2001 09:09:20 +0200
Hello Scripters !
I am trying to combine 2 Outlook express scripts:
The first one works perfectly. It performs bulk decoding on coded mail,
using the application "APICRYPT", and saving it to different folders.
It is widely inspired and adapted from Paul Berkovitz's "Messages to disk
v2" script.
The second one, renames each message from strings taken into it. It was
given here by Paul, too. Difficult to avoid Paul when you start Outlook
express or Entourage scripting ;-)
My purpose would be decrypting and then, rename each message, before saving
it.
To put it clearly, each one of the 2 scripts is working serarately fine. My
problem is to combine them.
As a stupid newbie, this has occupied a lot of my time, without success.
Thanks in advance.
Bernard, the *almost* suiciding french scripter.
================= FIRST SCRIPT DECODING AND SAVING ================
-- From Paul Berkovitz's "Messages to disk v2" script.
property pFolderPath : ""
global ctype
on run {}
set pFolderPath to "Microplis 1.6 Go:Applications (Mac OS
9):Internet:Tilichargement:HPRIM Import:" as text
set ctype to "TBB6"
tell application "Outlook Express"
activate
set theSelection to the current messages
set handledMessage to false
set msgCount to 0
repeat with theMessage in theSelection
my ProcessMessage(pFolderPath, theMessage)
set msgCount to msgCount + 1
set handledMessage to true
end repeat
if handledMessage = false then
display dialog "Vous devez silectionner au moins un message " &
,
"pour utiliser ce script." with icon note buttons {"OK"}
default button "OK"
else
beep
beep
end if
end tell
end run
(*Cette routine collecte le(s) message(s) silectionni(s) et appelle les
autres routines
pour le(s) traiter. *)
on ProcessMessage(folderpath, theMessage)
tell application "Outlook Express"
set {theBody, theFolder} to {content, name of storage} of theMessage
tell application "APICRYPT"
set theBody to ASCIIToBin theBody
quit
end tell
set TheText to theBody
set content of theMessage to TheText -- enregistre le message
dicrypti dans OutLook
move theMessage to folder "z Archives DECRYPTEES" -- et le diplace
dans le dossier d'archives
try
set subjectstr to subject of theMessage
on error
set subjectstr to "<aucun objet>"
end try
if subjectstr is equal to "" then set subjectstr to "<aucun objet>"
end tell
set fileName to ConvertToFileName(subjectstr)
set FilePath to CreatetheFile(folderpath, fileName)
SaveMessage(FilePath, TheText)
end ProcessMessage
(* ConvertToFileName
** d'aprhs David Cortright <email@hidden>
** modification du nom des fichiers.
** On ivite les noms refusis par le finder:
** nom comportant plus de 32 carathres et les ":" du chemin d'acchs)*)
on ConvertToFileName(theString)
-- Enlhve les ":" qui proviennent du chemin d'acchs, dans le nom du
fichier
set theString to my SearchReplace(theString, ":", "")
set stringLength to length of theString
if stringLength > 31 then set theString to (text 1 thru 31 of theString)
return theString
end ConvertToFileName
-- routine effectuant la recherche/remplacement dans le texte
on SearchReplace(mainString, searchString, replaceString) -- Paramhtres:
search, replace, the String
set olddelis to AppleScript's text item delimiters
set AppleScript's text item delimiters to (searchString)
set theList to (every text item of mainString)
set AppleScript's text item delimiters to (replaceString)
set theString to theList as string
set AppleScript's text item delimiters to olddelis
return theString
end SearchReplace
(* Cette routine enregistre le message silectionni dans le dossier
Temporaire d'Outlook Express.
Il sera ricupiri plus tard.*)
on CreatetheFile(folderpath, fileName)
tell application "Finder"
set FilePath to folderpath & fileName
set counter to 0
set originalname to fileName
set stringLength to length of fileName
if stringLength 31 then set originalname to (text 1 thru 28 of
fileName)
repeat while exists file FilePath
set counter to counter + 1
set counterstr to counter as string
set fileName to originalname & " " & counterstr
set FilePath to folderpath & fileName
end repeat
make file in folder folderpath with properties {name:fileName,
creator type:ctype}
end tell
return FilePath
end CreatetheFile
(* Cette routine ouvre le dossier Temporaire d'Outlook Express
et y copie la source du message silectioni*)
on SaveMessage(FilePath, theSource)
tell application "Finder"
set FileRefnum to (open for access file FilePath with write
permission) -- dossier Temporaire
write theSource to FileRefnum
close access FileRefnum
end tell
end SaveMessage
===================== END OF FIRST SCRIPT =========================
================= SECOND SCRIPT CHANGING MESSAGE TITLE ============
tell application "Outlook Express"
set theMsg to item 1 of (get current messages)
set theSubject to subject of theMsg
set theContent to content of theMsg
end tell
set AppleScript's text item delimiters to {"("}
set theNumber to text item - 1 of theSubject
set AppleScript's text item delimiters to {")"}
set theNumber to text item 1 of theNumber
set AppleScript's text item delimiters to {""}
repeat with i from 1 to (count (paragraphs of theContent) )
set theLine to paragraph i of theContent
if theLine contains "00000" then
set newContent to text (paragraph 2 of theContent) thru -1 of
theContent
exit repeat
end if
end repeat
set LastName to paragraph 1 of newContent
repeat while character 1 of of LastName = " "
set Lastname to text 2 thru -1 of LastName
end repeat
repeat while character -1 of of LastName = " "
set Lastname to text 1 thru -2 of LastName
end repeat
set FirstName to paragraph 2 of newContent
repeat while character 1 of of FirstName = " "
set FirstName to text 2 thru -1 of FirstName
end repeat
repeat while character -1 of of FirstName = " "
set FirstName to text 1 thru -2 of FirstName
end repeat
set newFilename to LastName & " " & Firstname & "(" & theNumber & ")"
=================== END OF SECOND SCRIPT =============================