Code: Select all
...
put getMailText(tEMLArray) into tText
...Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Code: Select all
...
put getMailText(tEMLArray) into tText
...
Code: Select all
on mouseUp 
   
   ## Let user select a EML file:
   answer file "EML"
   
   ## User clicked CANCEL so get out of this handler:
   if the result = "cancel" then
   	exit to top
   end if
   
   ## Put it into a variable:
   put url("file:" & it) into tData
   
   ## Let LC make the data an array:
   put emlToArray(tData) into tEMLArray
   
   ## I found that this does obviously not work with ALL emails, see my last postings...
   ## put tEMLArray["content"] into tText
   
   ## But this seems to work in most cases to get the actual BODY of the mail:
   put getMailText(tEMLArray) into tText
   
   ## Check tText in a field and see if you need to:
   ## put textdecode(tText,"utf8") into tTextClean
   
   ## Now you can continue with your last script from the previous page:
   ## headers is also an array and NOT a simple string, that is an error in the dictionary!
   put getHeaders(tData) into tHeaderArray
   put tHeaderArray["From"] into tFrom
   put tHeaderArray["To"] into tTo
   put tHeaderArray["Subject"] into tSubj
   put tHeaderArray["Date"] into tDate
   put tHeaderArray["Content-Transfer-Encoding"] into tContent
   put tTo & CR & tFrom & CR & tSubj & CR & tDate & CR & CR & tText
end mouseUp"content" MAY be a key of the tEMLArray, "body" does not!I notice your screenshot has an element call "content" but you refer to "body" a couple of times and I'm confused about the differences.

 
 Je suis tres reconnaissant, mon ami! This is the key to maybe 30,000+ old email files going back years which I have had very limited ways to manipulate. Very excited about this, and for future applications. When I saw EMLParser I knew I needed the Enhancements Pack (which, sadly I have only just gotten around to exploring). Too bad the documentation is so rudimentary (and even wrong, as you point out). It could use some samples of each step!
Code: Select all
...
put emlToArray(tData) into tArray
put getAttachments(tArray) into tAt
...Code: Select all
...
put emlToArray(tData) into tArray
put getAttachments(tArray) into tAt
...Code: Select all
...
put the keys of tAt into tFilenames
repeat with i = 1 to the num of lines of tFilenames
   ## tFileName now contains the name of the first KEY of tAt
   put line i of tFilenames into tFileName
   ## Save the images on the desktop:
   put base64decode(tAt[tFileName]) into url("binfile:" & specialfolderpath("desktop") "/" & tFileName)
end repeat
...Now, this is truly magic! The EML file actually contains photo and .pdf and .mp3 files locked away for 15 years!!Klaus wrote: ↑Mon Feb 26, 2024 6:08 pmUsing my example, e.g. store the images on the desktopCode: Select all
... put the keys of tAt into tFilenames repeat with i = 1 to the num of lines of tFilenames ## tFileName now contains the name of the first KEY of tAt put line i of tFilenames into tFileName ## Save the images on the desktop: put base64decode(tAt[tFileName]) into url("binfile:" & specialfolderpath("desktop") "/" & tFileName) end repeat ...