Anyone know of a tool that will export messages out of a Microsoft Outlook PST file to a text file? Preferably one that will run in Windows.
Printable View
Anyone know of a tool that will export messages out of a Microsoft Outlook PST file to a text file? Preferably one that will run in Windows.
Not really,
There are quite a few apps that convert from one mail system to another like:
http://www.aid4mail.com/?rf=g_convert_pst
And I believe that you can convert to XML for more stable archiving, but I don't know of anything that converts to text or rich text.
:)
Hey Hey,Quote:
Originally posted here by ric-o
Anyone know of a tool that will export messages out of a Microsoft Outlook PST file to a text file? Preferably one that will run in Windows.
This may be a stupid response, but how about Outlook??? it exports to csv and tab'd text files..
Peace
HT
Yeah I know...but I have somewhere around 50 of these and that would take forever using Outlook. I thought at one point I found a Linux LIVE CD-based tool but dont remember which one...plus it would be a lot easier to process these in Windoz.Quote:
Originally posted here by HTRegz
Hey Hey,
This may be a stupid response, but how about Outlook??? it exports to csv and tab'd text files..
Peace
HT
Hi,
What exactly are you trying to do ric-o ?
If it is mail transfer or conversion then I would recommend a conversion tool. You will still have to use Outlook as part of the process.
Outlook is complex, and is under Microsoft copyright. Part of this means that if you attempt to manipulate it through non-accepted methods you will certainly lose data.
You mention 50, which sounds like an organization, so legality has to be a consideration?.............and that would include security and confidentiality as well as copyright and EULAs.
So, what are you trying to move these PST files into?
:)
Nihil,
I'm simply trying to move the message data from Outlook PST into text files so I can run Perl scripts against it to analyze it and manipulate the data.
As far as the legality: I have the authority and legally can do this - I'm covered.
Ok....will have to use Outlook...hrm.
Hey! ric-o please do not think that I was questioning your morality, motivation, authorisation or whatever.................I was not!
I was just wondering what you were trying to achieve and pointing out that "Outlook" is an MS closed copyright hush, hush, application............... that was my meaning of "legality" :D I had naturally assumed that you had legal rights to the data et cetera..............
Unfortunately, my experience has only been converting from one client to another :( so I got it wrong?
Yes, you will have to use "Outlook" to open the stuff up with..............I wonder if those apps that convert to HTM files might not help?.................... like it may be a three stage process, rather than a two stage one????????
What versions of software are we talking here mate?
I can "make enquiries" then........................ ;)
No probs, we're good. :)Quote:
Originally posted here by nihil
Hey! ric-o please do not think that I was questioning your morality, motivation, authorisation or whatever.................I was not!
Yes, you will have to use "Outlook" to open the stuff up with..............I wonder if those apps that convert to HTM files might not help?.................... like it may be a three stage process, rather than a two stage one????????
What versions of software are we talking here mate?
Outlook 2003. Yeah, I saw a couple of those apps that do conversions to other clients (as you identified) - would have to do to Excel format, for example, and then export out of Excel to plain text.
I just counted the number of PSTs and I have 195 totalling 47GB. Most of these are backups that were made on a daily/weekly basis for example so there will definitely be duplicate data inside them.
Sigh. Thanks nihil for your help so far and anything you find out.
Hey Hey,Quote:
Originally posted here by ric-o
No probs, we're good. :)
Outlook 2003. Yeah, I saw a couple of those apps that do conversions to other clients (as you identified) - would have to do to Excel format, for example, and then export out of Excel to plain text.
I just counted the number of PSTs and I have 195 totalling 47GB. Most of these are backups that were made on a daily/weekly basis for example so there will definitely be duplicate data inside them.
Sigh. Thanks nihil for your help so far and anything you find out.
What sort of time frame do you have on this? and how important is it to you??
I've got a busy week ahead of me, but next weekend I should have some free time... I'm sure I could write something up real quick that'll do the export for you...
Peace,
HT
I'm not in a rush...got some time. Wow, that would be cool HT! Thanks.Quote:
Originally posted here by HTRegz
What sort of time frame do you have on this? and how important is it to you??
I've got a busy week ahead of me, but next weekend I should have some free time... I'm sure I could write something up real quick that'll do the export for you...
Not a problem... this is a little new to me... otherwise it'd be done.. (maybe.. heh)... I'm gonna see what I can do anyways...Quote:
Originally posted here by ric-o
I'm not in a rush...got some time. Wow, that would be cool HT! Thanks.
Hey Hey,Quote:
Originally posted here by HTRegz
Not a problem... this is a little new to me... otherwise it'd be done.. (maybe.. heh)... I'm gonna see what I can do anyways...
So I put in a bit of time while waiting for a phone call..
This will parse your Inbox in Outlook... and dump everything to a single text file in the root of c:
It requires Pythonwin from ActiveState for the win32com.client file...Code:import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application")
namespace = outlook.GetNamespace("MAPI")
inbox = namespace.GetDefaultFolder(6).Items
for item in inbox:
msgFrom = "From: " + str(item.sendername) + " (" + str(item.senderemailaddress) + "}"
msgTo = "To: " + str(item.to)
msgDate = "Date: " + str(item.ReceivedTime)
msgSubject = "Subject: " + str(item.subject)
msgBody = "Message: \n\n" + item.body.encode( "utf-8" )
fp = open("c:\outlookMessages.txt", "a")
fp.write("--- Start Message ---")
fp.write("\n")
fp.write(msgFrom)
fp.write("\n")
fp.write(msgTo)
fp.write("\n")
fp.write(msgDate)
fp.write("\n")
fp.write(msgSubject)
fp.write("\n")
fp.write(msgBody)
fp.write("\n")
fp.write("--- End Message ---")
fp.write("\n\n")
fp.close()
I'm working on parsing pst files themselves for this.. but I've hit a problem with namespace.addstore() but I'll see what I can do..
Peace,
HT
Hi
Excellent work HTRegz. I was actually inspired by your comments, and
wrote a little VBA-Script, which allows for an easy automation of
the task without external tools.
The following VBA-macro (runs in Outlook) stores each message as a
"datetime_from.txt"-file in the folder c:\test, and stores its attachments in
the folder c:\test\att.
It does not handle multiple folders with mail-items; it just uses the default inbox.
This could/should be extended, and I could do it for you, ric-o, if needed...
Note, that maybe, one has to change the security level[1], except one knows how
to sign the code.
How does the automation work:
Part A: create the basis
1. create a directory c:\test and c:\test\att
2. create an outlook profile "export", configured for an outlook-pst file c:\test\temp.pst
3. make sure that outlook opens automatically c:\test\temp.pst when starting outlook ("export" as default profile)
4. in outlook: open the VBA-Editor by pressing Alt-F11
5. add the code below in the existing module or create a new one
6. save and test it in the VBA-Editor: it should export the Inbox-Folder and close Outlook
7. start outlook again. the macro now should be available in the macro-list in Outlook (Alt-F8)
8. exit outlook and start it once again by using the command line parameter
" ...outlook.exe /autorun Export_Inbox" (works only in Outlook 2003). At startup, outlook
will run the Macro "Export_Inbox" (which then closes outlook).
9. remove the directory c:\test
Part B: do the loop
Create a batch-file that does the following:
a) create the c:\test and c:\test\att-folders
b) copy "pst_1.pst" (or whatever) to c:\test\temp.pst
c) start outlook as above with the /autorun-option: -> the export is running
d) delete the file c:\test\temp.pst
e) rename the test-folder or move it to wherever you want
f) loop to a) and copy the next pst-file.
Cheers :)Code:Sub Export_Inbox()
On Error GoTo ErrorOcccured
Dim ns As namespace
Dim inbox As MAPIFolder
Dim item As Object
Dim att As Attachment
Dim mail As String
Dim filename As String
' open Default Inbox
Set ns = GetNamespace("MAPI")
Set inbox = ns.GetDefaultFolder(olFolderInbox)
If inbox.Items.Count = 0 Then
Exit Sub
End If
' loop the items (emails)
For Each item In inbox.Items
mail = "From: " & item.SenderName & " (" & item.SenderEmailAddress & ") " & vbCrLf
mail = mail & "To: " & item.To & vbCrLf
mail = mail & "Cc: " & item.CC & vbCrLf
mail = mail & "Date: " & item.ReceivedTime & vbCrLf
mail = mail & "Subject: " & item.Subject & vbCrLf
mail = mail & "Attachments: "
' loop the attachments
For Each att In item.Attachments
filename = "C:\test\att\" & att.filename
att.SaveAsFile filename
mail = mail & att.filename & vbTab
Next att
mail = mail & vbCrLf & "Message: " & vbCrLf & vbCrLf & item.Body & vbCrLf
filename = "c:\test\" & Format(item.ReceivedTime, "ddmmyyyyhhmmss") & "_" & item.SenderName & ".txt"
Open filename For Append Access Write As #1
Print #1, mail
Close #1
Next item
Destructor:
Set att = Nothing
Set item = Nothing
Set ns = Nothing
' exit Outlook to allow for automation
Set MyOutlook = CreateObject("Outlook.Application")
MyOutlook.Quit
Set MyOutlook = Nothing
Exit Sub
ErrorOcccured:
MsgBox (Err.Number & vbCrLf & Err.Description)
Resume Destructor
End Sub
[1] http://office.microsoft.com/en-gb/as...850551033.aspx
I have used a program before called Dawn. Its freeware. It has a ton of options that I have not had the need for, maybe it might be of use for you:
"Dawn converts Address Books among various Address Book Programs.
Dawn is equipped with an extraction feature. It is absolutely free to use
and distribute in the form seen here, but the source code is not freely
distributable.
New in this release: vCard (VCF) support, Outlook 2003 support, Many new fields supported, Bug fixes for the CSV format, Opera, Mozilla, Netscape, and others
Dawn works with the following programs:
Becky!, Pine (for PC and UNIX), Mozilla, Netscape 6/7, Netscape Communicator 4.x, Netscape Navigator 3.x, Opera, Outlook Express / Windows Address Book (WAB), Outlook 98/2000/2002/2003, Palm Desktop, Simeon, ExecMail, Juno, Corel WordPerfect Address Book 8.x, Eudora 3.x, 4.x, 5.x, 6.x, Pegasus Mail 3.x and 4.x, Other programs which can use/import/export LDAP/LDIF, Comma Separated Value (CSV), vCard (VCF), plain text, one per line or comma separated formats or store addresses in a text file"
There was also this: http://www.processtext.com/abcoutlk.html
But I think you have plenty of good options now ;)
HT, sec_ware - you guys ROCK! Thanks a ton for the help! I'm fooling around with them now. Will let you know if any questions or need more help. (AO aint letting me give you peeps any greenies at this point..sorry).
Nihil, Spyrus, Eyecre8, thanks to you for those apps too.
Hi
ric-o and me, we discussed the issue during the past few days, and performed
a few tests. Our script now is capable to extract all emails (and attachments) from
all email-folders stored in a pst-file. The content of an email-folder is stored
in a separate file (Ã* la HTRegz).
In order to allow for automation, Outlook may have to be configured not to show the
reminders (Options.Advanced.Reminder Options). Note that Outlook 2003 is needed
for the /autrun-option.
We hope that this may help others as well.
Cheers
Code:
' Idea of the recursive handling taken from Michael Bauer[1].
Sub HandleAllItems(oRoot As Outlook.namespace, _
ByVal bRecursive As Boolean _
)
LoopFolders oRoot.Folders, bRecursive
End Sub
Sub LoopFolders(oFolders As Outlook.Folders, ByVal bRecursive As Boolean)
Dim oFld As Outlook.MAPIFolder
' Loop through all folders.
For Each oFld In oFolders
' Loop through folder items
LoopItems oFld.Items, oFld.Name
If bRecursive Then
' Call this function again for going _
deeper into the object hierarchy.
LoopFolders oFld.Folders, bRecursive
End If
Next
End Sub
Sub LoopItems(oItems As Outlook.Items, FolderName As String)
Dim obj As Object
For Each obj In oItems
Select Case True
Case TypeOf obj Is Outlook.MailItem
HandleMailItem obj, FolderName
End Select
Next
End Sub
Sub HandleMailItem(oItem As Outlook.MailItem, FolderName As String)
Dim mail As String
Dim filename As String
mail = "--- Begin Message ---" & vbCrLf
mail = mail & "From: " & oItem.SenderName & " (" & oItemSenderEmailAddress & ") " & vbCrLf
mail = mail & "To: " & oItem.To & vbCrLf
mail = mail & "Cc: " & oItem.CC & vbCrLf
mail = mail & "Date: " & oItem.ReceivedTime & vbCrLf
mail = mail & "Subject: " & oItem.Subject & vbCrLf
mail = mail & "Attachments: "
' loop the attachments
For Each att In oItem.Attachments
filename = "C:\test\att\" & att.filename
att.SaveAsFile filename
mail = mail & att.filename & vbTab
Next att
mail = mail & vbCrLf & "Message: " & vbCrLf & vbCrLf & oItem.Body & vbCrLf
mail = mail & "--- End Message ---" & vbCrLf
filename = "c:\test\" & FolderName & ".txt"
Open filename For Append Access Write As #1
Print #1, mail
Close #1
End Sub
Sub Export_Inbox()
On Error GoTo ErrorOcccured
Dim ns As namespace
Set ns = GetNamespace("MAPI")
HandleAllItems ns, True
Destructor:
Set ns = Nothing
' exit Outlook to allow for automation
Set MyOutlook = CreateObject("Outlook.Application")
MyOutlook.Quit
Set MyOutlook = Nothing
Exit Sub
ErrorOcccured:
MsgBox (Err.Number & vbCrLf & Err.Description)
Resume Destructor
End Sub
[1] http://www.office-loesung.de/ftopic36102_0_0_asc.php
If you want to use Perl, take a look at Mail::Outlook from CPAN.
Here is part of the example crom CPAN:
use Mail::Outlook;
my $outlook = new Mail::Outlook();
# start with a folder
my $outlook = new Mail::Outlook('Inbox');
# use the Win32::OLE::Const definitions
use Mail::Outlook;
use Win32::OLE::Const 'Microsoft Outlook';
my $outlook = new Mail::Outlook(olInbox);
# get/set the current folder
my $folder = $outlook->folder();
my $folder = $outlook->folder('Inbox');
# get the first/last/next/previous message
my $message = $folder->first();
$message = $folder->next();
$message = $folder->last();
$message = $folder->previous();
# read the attributes of the current message
my $text = $message->From();
$text = $message->To();
$text = $message->Cc();
$text = $message->Bcc();
$text = $message->Subject();
$text = $message->Body();
-GA