Cush Posted April 5, 2006 Posted April 5, 2006 Hi, I have an App that needs to read emails that I've dragged into a folder from Outlook Express. Unfortunately, the email is an .eml file, and my App needs a .txt file. I can only think of clunky ways to Automate this via Notepad - is there an easier way? Thanks Paul
BigDod Posted April 5, 2006 Posted April 5, 2006 Hi,I have an App that needs to read emails that I've dragged into a folder from Outlook Express. Unfortunately, the email is an .emlfile, and my App needs a .txt file. I can only think of clunky ways to Automate this via Notepad - is there an easier way?ThanksPaulIn Outlook Express you can use the Save As function to save an email as a .txt file. You could write an AutoIt script to do this. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother
MHz Posted April 5, 2006 Posted April 5, 2006 (edited) Eml files do seem to be just txt files. OE seems to just cut down from the top to the From: line and saves from there onwards. Here is a UDF that can do a folder of the Eml files. expandcollapse popup; Enter folder as UDF parameter _Eml2Txt('c:\folder') Func _Eml2Txt($directory) Local $file_temp = @TempDir & '\MailConverter.txt' Local $file_eml, $file_temp, $handle_read Local $handle_search, $handle_write, $line FileChangeDir($directory) $handle_search = FileFindFirstFile('*.eml') If $handle_search <> -1 Then While 1 $file_eml = FileFindNextFile($handle_search) If @error Then ExitLoop If $file_eml = '.' Or $file_eml = '..' Then ContinueLoop $handle_read = FileOpen($file_eml, 0) $handle_write = FileOpen($file_temp, 2) While 1 $line = FileReadLine($handle_read) If @error Then ExitLoop While StringLeft($line, 5) <> 'From:' ContinueLoop 2 WEnd While 1 FileWriteLine($handle_write, $line) $line = FileReadLine($handle_read) If @error Then FileClose($handle_write) FileClose($handle_read) FileMove($file_temp, StringReplace($file_eml, '.eml', '.txt')) ExitLoop 2 EndIf WEnd WEnd WEnd FileClose($handle_search) FileDelete($file_temp) EndIf EndFunc It will save the txt files in the same folder. Edit: Localized all needed variables. Edited April 5, 2006 by MHz
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now