faqts : Computers : Programming : Languages : Bbcbasic

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 2 people (50%) answered Yes
Recently 1 of 2 people (50%) answered Yes

Entry

BBCBASIC: Windows: Can you give a simple program to read e-mails from Mozilla Thunderbird mail file?

Oct 22nd, 2006 04:44
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 22 October 2006 - 01:24 am --------------------
BBCBASIC: Windows: Can you give a simple program to read e-mails from 
Mozilla Thunderbird mail file?
The idea is that if you convert your Microsoft Outlook Express e-mails
using Mozilla Thunderbird, that you get a readable ASCII
representation. Each e-mail starts with 'From -'. You then split your
file in subfiles where each of this files contains 1 of this e-mails.
---
You can then do something with each of this text files.
E.g. add a POP header to it to send it to your e-mail SMTP server (e.g.
GMail (which can then e.g. forward it to e.g. Yahoo mail)
===
Steps: Overview:
 1. -Each of your Microsoft Outlook Express folders corresponds to
     1 .dbx file with the same name.
     E.g. Inbox is stored in the file Inbox.dbx
 2. -The location of this Microsoft Outlook Express .dbx files you
     can find e.g. by starting Microsoft Outlook Express,
     menu 'Tools', 'Options', 'Maintenance', 'Store folder'
     then copy this file path from beginning to end to the clipboard
 3. -Convert your Microsoft Outlook Express e-mail .dbx files to .msf
     files using e.g. Mozilla Thunderbird
     1. -This automatic conversion (which you can start directly after
         installation will create for each of Microsoft Outlook Express
         'yourFilename.dbx' files 2 corresponding files
          yourFilename.msf
          and
          yourFilename
     2. -The location of this Mozilla Thunderbird directory is usually
          c:\documents and settings\<your Windows user 
name>\Application data\Thunderbird\Profiles\vuncu33m.default\Mail\
         (in MSDOS, type
           cd %appdata%
           cd Thunderbird
           cd Profiles
           and go from there on to the Mail folder
     2. -It is the file
          yourFilename
         which contains all your e-mail in readable ASCII text format
         which you have to use here (so do not use the .msf file)
         (the 'yourFilename.msf' file contains formatting information
         and should not be used here by us)
 4. -You read all this e-mails in 1 of this ASCII text files
 5. -Each of this e-mails typically looks like this
--- cut here: begin --------------------------------------------------
From - Mon Jan 1 00:00:00 1965
X-Mozilla-Status: 0000
X-Mozilla-Status2: 00000000
X-Apparently-To: [email protected] via 166.18.4.4; Wed, 06 Oct 2004 
14:20:04 -0700
X-Originating-IP: [112.136.26.145]
Return-Path: <[email protected]>
Received: from 112.136.26.145  (EHLO bla.bla.com) (112.136.26.145)
  by bla.mail.dcn.mycompany.com with SMTP; Wed, 06 Oct 2004 14:20:03 -
0700
Received: from mail pickup service by bla.bla.com with Microsoft 
SMTPSVC;
         Wed, 6 Oct 2004 14:18:57 -0700
From: <[email protected]>
To: <[email protected]>
Subject: Shipping Confirmation
Date: Wed, 6 Oct 2004 14:18:57 -0700
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <[email protected]>
X-OriginalArrivalTime: 06 Oct 2004 21:18:57.0781 (UTC) FILETIME=
[177A6250:01C4ABEA]
Dear customer,
We are pleased to inform you that we have dispatched your order number
You should receive your order within 8 to 14 working days.
If you have any questions or concerns please contact us at
[email protected]  Please include your order number to
ensure a prompt reply.
--- cut here: end ----------------------------------------------------
 6. -You get each e-mail by reading all lines of this ASCI text file
     1. -Search for the word 'From -' in the beginning of each line
         1. -When 'From -' is found
             1. -Possibly close the last open output file
             2. -Open the next output file
         2. Otherwise
            -Write the current line to the current output file
 7. -Create thus e.g. the following program
--- cut here: begin --------------------------------------------------
 PROCFileGetEmailReadAllSimple( "c:\Documents and 
Settings\Administrator\Application 
Data\Thunderbird\Profiles\vuncu33m.default\Mail\Local 
Folders\Amazon", "c:\temp\ddd100" )
 END
 :
 :
 :
 REM library: file: get: line: read: all: simple [kn, ri, th, 21-09-
2006 22:31:09]
 DEF PROCFileGetEmailReadAllSimple( filenameInput$, directory$ )
 LOCAL byteI%
 LOCAL character$
 LOCAL fileInputP%
 LOCAL fileOutputP%
 LOCAL filenameOutput$
 LOCAL line$
 LOCAL lineI%
 filenameInput$ = filenameInput$ + "." : REM add dot as (no file 
extension assumed)
 fileInputP% = OPENIN( filenameInput$ )
 characterI% = 1 - 1
 emailI% = 1 - 1
 lineI% = 1
 character$ = ""
 line$ = ""
 IF ( fileInputP% = 0 ) THEN PRINT "file:" + " " + filenameInput$ 
+ " " + "could not be found" : ENDPROC
 WHILE NOT ( EOF #fileInputP% )
   byteI% = BGET #fileInputP%
   characterI% = characterI% + 1
   IF ( byteI% = 13 ) THEN
     byteI% = BGET #fileInputP% : REM get CHR$( 10 ) which follows 
CHR$( 13 )
     REM you found begin of e-mail
     IF ( LEFT$( line$, LEN "From -" ) = "From -" ) THEN
       IF ( emailI% > 1 ) THEN CLOSE #fileOutputP% : REM close after 
processing 1st, 2nd, ... e-mail is finished
       emailI% = emailI% + 1 : REM you count the total amount of e-
mails
       filenameOutput$ = directory$ + "\e-mail" + STR$( emailI% ) 
+ ".txt" : REM create 'unique' filename
       fileOutputP% = OPENOUT filenameOutput$
       PRINT; "creating file" + " " + filenameOutput$
     ENDIF
     PRINT #fileOutputP%, line$
     lineI% = lineI% + 1
     characterI% = 1 - 1
     line$ = ""
   ELSE
     character$ = CHR$( byteI% ) : REM convert the byte to an ASCII 
character
     line$ = line$ + character$ : REM and add this ASCII character at 
the end of the current line
   ENDIF
 ENDWHILE
 CLOSE #fileInputP%
 CLOSE #fileOutputP%
 ENDPROC
 :
--- cut here: end ----------------------------------------------------
 8. -You call it with
      PROCFileGetEmailReadAllSimple(
       <path to 1 Mozilla Thunderbird ASCII mail file>,
       <path to your output directory where you store each of this 
extracted e-mails>
      )
     E.g.
      PROCFileGetEmailReadAllSimple(
       "c:\Documents and Settings\Administrator\Application 
Data\Thunderbird\Profiles\vuncu33m.default\Mail\Local Folders\Amazon",
       "c:\temp\ddd100"
      )
 9. -Run the program
10. -That will store each of the e-mails of this ASCII mail file in a
     separate file
     1. -E.g.
          Here you see that 22 e-mails are extracted out of this
          mail file and each e-mail is stored in a separate file
--- cut here: begin --------------------------------------------------
> dir "c:\temp\ddd100"
 Volume in drive C is unlabeled      Serial number is 6cbc:c01a
 Directory of  C:\TEMP\DDD100\*
   10/22/2006   2:03         <DIR>    .
   10/22/2006   2:03         <DIR>    ..
   10/22/2006   2:03           7,430  e-mail1.txt
   10/22/2006   2:03           2,527  e-mail2.txt
   10/22/2006   2:03             805  e-mail3.txt
   10/22/2006   2:03           5,666  e-mail4.txt
   10/22/2006   2:03           7,896  e-mail5.txt
   10/22/2006   2:03          10,039  e-mail6.txt
   10/22/2006   2:03          10,308  e-mail7.txt
   10/22/2006   2:03           1,798  e-mail8.txt
   10/22/2006   2:03           1,755  e-mail9.txt
   10/22/2006   2:03           4,902  e-mail10.txt
   10/22/2006   2:03          16,368  e-mail11.txt
   10/22/2006   2:03           2,636  e-mail12.txt
   10/22/2006   2:03           2,334  e-mail13.txt
   10/22/2006   2:03           2,755  e-mail14.txt
   10/22/2006   2:03          14,946  e-mail15.txt
   10/22/2006   2:03          11,309  e-mail16.txt
   10/22/2006   2:03           2,839  e-mail17.txt
   10/22/2006   2:03           3,669  e-mail18.txt
   10/22/2006   2:03           2,668  e-mail19.txt
   10/22/2006   2:03           2,765  e-mail20.txt
   10/22/2006   2:03           2,927  e-mail21.txt
   10/22/2006   2:03           1,273  e-mail22.txt
  119,615 bytes in 22 files and 2 dirs    155,648 bytes allocated
  2,029,420,544 bytes free
--- cut here: end ----------------------------------------------------
11. -You can then e.g. do further actions on each of this
     files
     1. -E.g.
          Add a e-mail header to it with the destination address
          (like <your e-mail address at GMail>
          and send this to GMail.
===
Tested successfully on
Microsoft Windows XP Professional (service pack 2),
running
Mozilla Thunderbird v7.1
Microsoft Outlook Express v6
BBCBASIC for Windows v5.30a
===
Internet: see also:
---
Language: Computer: BBCBASIC: Windows: How to possibly send an e-mail 
via BBCBASIC for Windows?
http://www.faqts.com/knowledge_base/view.phtml/aid/39320/fid/768
---
Uploading Old Email to Gmail using Java
http://www.developer.com/java/other/article.php/3557116
---
How to Import Archived Outlook Email Into GMail Using GML
http://www.wikihow.com/Import-Archived-Outlook-Email-Into-GMail-Using-
GML
---
Google GMail Loader (GML)
http://www.marklyon.org/gmail/gmailapps.htm
---
TSE: E-mail: Backup: Create: How to possibly create a backup of 
Microsoft Outlook Express e-mails?
http://www.faqts.com/knowledge_base/view.phtml/aid/23497/fid/896
----------------------------------------------------------------------