Hello,
I hope somebody can help me. I’ve asked a lot of people, but no one seems to know the answer.
Here is the problem: :?:
I want to have a Applescript that saves selected emails in a folder in the Finder. So not the whole folder but just one or more selected emails in that folder. The folder in the Finder has exact the same name as the folder in OE.
And if it’s possible the files that are saved in the Finder have the same date and time as the email itself. :o
Who can make me such a script?? Or tell me how to do it?? :oops:
Thanks in advance.
Have Fun
Fons
Let me see if I understand what you are looking for.
You want a script that will basically drag the emails you have selected into a folder in the Finder with the same name as the folder it was found in - in OE?
This script will do that- let me know if this isn’t what you are looking for.
--first, set up a root folder where all your OE matching folders will be found
property rootFolder : "TWS-0103:Desktop Folder:Save Emails:"
tell application "Outlook Express"
set fileThese to the selection
repeat with fileThis in fileThese --repeat with every message currently selected
set thisFolder to the name of storage of fileThis --get the name of the folder this email is stored in
try
set saveHere to rootFolder & thisFolder as alias --see if the folder exists in the Finder
--if it does not fail, save the email to the folder
save fileThis in saveHere
--delete fileThis --optionally delete the email if you want to uncomment this line
on error
--figure out something to do with this email since the folder wasn't found
--or create the folder you need and keep going
end try
end repeat
end tell
Best,
Hi Mytzlscript,
Thanks for your reply.
Yes that’s exactly what I want to do.
I’ve tried the scrip but it didn’t work. To see where it goes wrong I’ve put 2 display’s in it:
try
display dialog ("after try") buttons {"Ok"} default button {"OK"} giving up after 30
set saveHere to rootFolder & thisFolder as alias --see if the folder exists in the Finder
display dialog ("after saveHere ") buttons {"Ok"} default button {"OK"} giving up after 30
--if it does not fail, save the email to the folder
save fileThis in saveHere
--delete fileThis
--optionally delete the email if you want to uncomment this line on error
display dialog (" on error") buttons {"Ok"} default button {"OK"} giving up after 30
--figure out something to do with this email since the folder wasn't found
--or create the folder you need and keep going
end try
First I get the display “after try” and then I get the display “on error”. So it seems that that the “set saveHere to rootFolder & thisFolder as alias” doesn’t work. Perhaps I need a special set of osax or something like that??
Fons
apanken,
Perhaps you need to change the name of the HD. The code I supplied contains the name of my HD.
--first, set up a root folder where all your OE matching folders will be found
property rootFolder : "Your HD Name Here:Desktop Folder:Save Emails:"
To verify your folder exists do this:
set rootFolder to "The name of your HD:Some Folder:Some Other Folder:" as alias
If this fails - you are pointing it at a folder that doesn’t exist. Make sure the path to your root folder ends with a colon - “:”
The only other thing I can think of is maybe you don’t have any emails selected when you are running the script.
This script works for me on OE 5 on both Os 9.2.1 and Os 8.6
Here is the script again in its entirety.
--first, set up a root folder where all your OE matching folders will be found
property rootFolder : "Your HD Name:Desktop Folder:Save Emails:"
--this must be a valid path to a folder, and must end with a colon
tell application "Outlook Express"
set fileThese to the selection --if you don't have emails selected nothing will work
repeat with fileThis in fileThese --repeat with every message currently selected
set thisFolder to the name of storage of fileThis --get the name of the folder this email is stored in
try
set saveHere to rootFolder & thisFolder as alias --see if the folder exists in the Finder
--if it does not fail, save the email to the folder
save fileThis in saveHere --this must be enclosed withing the tell OE block
--delete fileThis --optionally delete the email if you want to uncomment this line
on error
--figure out something to do with this email since the folder wasn't found
--or create the folder you need and keep going
end try
end repeat
end tell
Good luck my friend,
Mytzlscript,
You’re great. I did change the name of the HD and checked it by another display.
:oops: But I just forgot the colon :oops:
So thank you very mutch. It works fine now.
Is it possible to give the files (that are saved) the same date and time as the email itself??? Or can this be done with another script??
Have Fun
Fons
email: Fons@vraagt.vaak.nl.invalid Remove dot_invalid
Fons,
This appears to work, though I haven’t tested it thoroughly.
I only added a few lines:
-
to get the message received date
-
to change the modification date of the email you are saving
to match the received date.
Hope this is what you were looking for.
--first, set up a root folder where all your OE matching folders will be found
property rootFolder : "Mac HD:Desktop Folder:Save Emails:"
--this must be a valid path to a folder, and must end with a colon
tell application "Outlook Express"
set fileThese to the selection --if you don't have emails selected nothing will work
repeat with fileThis in fileThese --repeat with every message currently selected
set thisFolder to the name of storage of fileThis --get the name of the folder this email is stored in
try
set saveHere to rootFolder & thisFolder as alias --see if the folder exists in the Finder
set messageDate to the time received of fileThis
--if it does not fail, save the email to the folder
set savedFile to save fileThis in saveHere --this must be enclosed withing the tell OE block
--delete fileThis --optionally delete the email if you want to uncomment this line
--to change the modification date of the email you just saved...
--set folderPath to rootFolder and thisFolder as string
set subFolder to rootFolder & thisFolder & ":" as string
tell application "Finder"
set the modification date of the last file of folder subFolder to messageDate
end tell
--set the modification date of thisFile to
on error
--figure out something to do with this email since the folder wasn't found
--or create the folder you need and keep going
set foo to "fee"
end try
end repeat
end tell
Best,
Mytzlscript,
I’ve tested the script and is works and it doesn’t work. If I select just one mail it works fine. But when I select more mails then some of them get the correct date and the others get the current date. It seems that the Finder is not that fast.
So I put in a display:
tell application "Outlook Express"
set fileThese to the selection
set counter to 0
repeat with fileThis in fileThese --repeat with every message currently selected
set thisFolder to the name of storage of fileThis --get the name of the folder this email is stored in
try
set counter to counter + 1
set saveHere to rootFolder & thisFolder as alias --see if the folder exists in the Finder
set messageDate to the time received of fileThis
--if it does not fail, save the email to the folder
set savedFile to save fileThis in saveHere --this must be enclosed withing the tell OE block
--save fileThis in saveHere
--to change the modification date of the email you just saved...
--set folderPath to rootFolder and thisFolder as string
set subFolder to rootFolder & thisFolder & ":" as string
tell application "Finder"
set the modification date of the last file of folder subFolder to messageDate
end tell
--set the modification date of thisFile to
if counter is equal to 1 then
display dialog ("One email exported to folder "" & thisFolder & "" in "" & rootFolder & """) buttons {"Ok"} default button {"OK"} giving up after 1
else
display dialog ("" & counter & " emails exported to folder "" & thisFolder & "" in "" & rootFolder & """) buttons {"Ok"} default button {"OK"} giving up after 1
end if
--delete fileThis --optionally delete the email if you want to uncomment this line
on error
display dialog (" There is an error") buttons {"Ok"} default button {"OK"} giving up after 30
--figure out something to do with this email since the folder wasn't found
--or create the folder you need and keep going
end try
end repeat
end tell
And now it works fine!!
Thanks again!!
Is it possible to save the emailadress from the person who sent me the mail and the to-adress to save it together in the remarks of the file??
Now this is one of the rules
How can I save the emailadresses in the remarks, so that I can see it in the Finder
Thanks again.
This worked for me.
set rootFolder to "Macintosh HD:Desktop Folder:Save Emails:"
tell application "Outlook Express"
set fileThese to the selection
set counter to 0
repeat with fileThis in fileThese --repeat with every message currently selected
set thisFolder to the name of storage of fileThis --get the name of the folder this email is stored in
--try
set counter to counter + 1
set saveHere to rootFolder & thisFolder as alias --see if the folder exists in the Finder
set messageDate to the time received of fileThis
--//ADD THIS
set theSender to the sender of fileThis --get the sender of the email
set theRecip to the address of recipient 1 of fileThis
set recipAddress to address of theRecip
set commentText to "From: " & address of theSender & return & "To: " & recipAddress as text --remove item 2 if you don't want the display name
--//
--if it does not fail, save the email to the folder
set savedFile to save fileThis in saveHere --this line would not work for me unless I removed the text "set savedFile to", but I am on an older OS at home
--save fileThis in saveHere
--to change the modification date of the email you just saved...
--set folderPath to rootFolder and thisFolder as string
set subFolder to rootFolder & thisFolder & ":" as string
tell application "Finder"
set the modification date of the last file of folder subFolder to messageDate
--//AND ADD THIS
set the comment of the last file of folder subFolder to commentText --set the comment of the file to the email address
--//
end tell
--set the modification date of thisFile to
if counter is equal to 1 then
display dialog ("One email exported to folder "" & thisFolder & "" in "" & rootFolder & """) buttons {"Ok"} default button {"OK"} giving up after 1
else
display dialog ("" & counter & " emails exported to folder "" & thisFolder & "" in "" & rootFolder & """) buttons {"Ok"} default button {"OK"} giving up after 1
end if
--delete fileThis --optionally delete the email if you want to uncomment this line
-- on error
display dialog (" There is an error") buttons {"Ok"} default button {"OK"} giving up after 30
--figure out something to do with this email since the folder wasn't found
--or create the folder you need and keep going
-- end try
end repeat
end tell
hi Mytzlscript,
You’re amazing. It works just as i wanted!! Great!! :lol:
When I want to save the sent date of the email as the creation-date of the file is this than correct??
And later these lines:
I tried it, but I get an error. What do I wrong??
When i import a saved mail it gets the date of today. Is it possible with a script to give him the received date from the internetheaders??
How can i count the number of emails in a specific folder within Outlook Express; for example the folder “Post IN”.
I’ve already have something but I can’t point it to the right folder.
I’m a shamed to ask you so many questions, but I’m going to enjoy it more and more.
Thanks again
This should work as is. I am able to use this code to get the message time of an email and turn around and use the Finder to change a file’s mod date to it. What is the error you are getting and where?
set receivedDate to the time received of fileThis
This should get the date that this email was received. Try this to verify if you don’t have a script editor that allows you to step thru your script/
set receivedDate to the time received of fileThis
set messageDateAsString to receivedDate as string
display dialog messageDateString
this will stop the script and show you what it thinks the received date is. It works for me in getting the date the message was originally received.
set messageCount to the count of messages in folder "Post IN"
If you want to use a different folder you can change “Post IN” to it and get the count of messages in that folder.
Again, post the error you are getting with the date and when it happens. In order to change the modification date your data has to be formatted as a date, and not as text. The code in our solution gets the message received date as a date on my computer. Maybe post the actual text this line returns for you. It could be returning a date format unusable for working with mod dates.
Good Luck!
Hi Mytzlscript,
When I try this
set receivedDate to the time received of fileThis
set messageDateAsString to receivedDate as string
display dialog messageDateString
Than it shows me :
the date when I imported it, but not the original received date.
In the internetheader I can see that there are 3 received dates
When i get one of them it is oke.
Indeed I can see the date because I’ve put the display in the script. But it goes wrong when the Finder tries to save it. Then I get this (translated) error about the creation date:
and so on. So perhaps “creation date” is wrong. Because when I replace “creation date” with “modification date”, than it works fine. Or maybe “creation date” is a read-only item and can’t be changed?? :?
set messageCount to the count of messages in folder "Post IN"
This worked fine!
Thanks again!