| Code level: beginner Code area: Basic Outlook Printer Friendly Version | ||
| Title: Export Outlook Folders to File Folders | ||
| Description: This VB application will export selected Outlook folders to file system as MSG files. The intent is to allow quick reference when burned to CD due to Outlook not opening 'Read Only' PST files. | ||
| Date: 25-Feb-2005 13:25 | ||
| Code level: beginner | ||
| Code area: Basic Outlook | ||
| Posted by: Steven Harvey | ||
| Body: |
||
| All 78comments |
| Page [ 1 2 3 4 5 6 7 8 Next >> ] | ||
|
|
Steven Harvey
25-Feb-2005 21:27
The project needs to reference the Outlook Object library. |
|
|
|
Steven Harvey
25-Feb-2005 21:34
This has been tested with Outlook 2000 and 2002. It may or may not work in 2003. This application will trigger security prompt. |
|
|
|
Steven Harvey
28-Feb-2005 08:21
76 downloads and no comments? I was hoping for some feedback to fine tune my abilities. Ahh well, enjoy! |
|
|
|
Sue Mosher
28-Feb-2005 21:56
It should work in Outlook 2003 -- and without security prompts. Lots of nice pieces here for someone wanting to work with the Win API folder dialog, etc. |
|
|
|
Steven Harvey
03-Mar-2005 10:00
Some reasons that an export will fail are: 1) Encrypted message and client doesnt have proper certificate. 2) Too long of filename/path. I have tried to account for this but some people have very deep folder structures with long names. 3) The script will push system memory usage when huge PST files are fully exported. I have tried to account for this with 'blahblah = Nothing' statements in loops so keep them there! I have assembled this from the information and code snippets I have found here on this website. Sue is my hero. I have purchased her book and would highly suggest you do too. It offers so much more and is very easy to understand. I will be a guru in no time! Please post your code if you feel it would benefit others. |
|
|
|
Sanan
05-Mar-2005 12:47
Hi there I want to do some thing similer, But I would like to send the infos to an Access Table. Could you tell me what is wrong with my codes Using Following codes I am trying to Loop through an OutLook folder Let’s say OutBox folder and Import Some of it’s data to Table of mine in Access Application; Private Sub cmdExport_Click() Dim olookApp As Outlook.Application Dim olookMsg As Object Dim olookSpace As Outlook.NameSpace Dim olookFolder As Outlook.MAPIFolder Set olookApp = CreateObject("Outlook.Application") Set olookSpace = olookApp.GetNamespace("MAPI") Set olookFolder = olookSpace.GetDefaultFolder(olFolderOutbox) Dim dbs As Database Dim rst As Recordset Dim strTitle As String Dim strFirstName As String Dim strMiddleName As String Dim strLastName As String Dim strJobTitle As String Dim strCompany As String Dim strBusinessPhone As String Dim strHomePhone As String Dim strHomeFax As String Dim strEMailAddress As String Dim strMessage As String Set dbs = CurrentDb Set rst = dbs![tblContacts].OpenRecordset(dbOpenTable, dbDenyRead) For Each olookMsg In olookFolder.Items rst.AddNew [FirstName] = strFirstName [MiddleName] = strMiddleName [LastName] = strLastName [JobTitle] = strJobTitle [Company] = strCompany [BusinessPhone] = strBusinessPhone [HomePhone] = strHomePhone [HomeFax] = strHomeFax [Message] = strMessage [E-mailAddress] = strEMailAddress Next End Sub |
|
|
|
Steven Harvey
06-Mar-2005 10:22
Hello Sanan, The below example is a basic start of an export to database macro. I only work with email in it but you will easily be able to figure out how to export other items. You may need better error checking in the database routines also. I didnt want to spend all day on this. This code will trigger security prompts. I have only tested in Outlook2k but it should work in the others with minimal or no modifications. Place the below code in a new or current module. [Start Code] Sub ExportToDatabase() 'Main macro for this example 'Helper functions are ProcessFolder and SearchForFile Dim olApp As Outlook.Application Dim olNS As Outlook.NameSpace Dim objFolder As Outlook.MAPIFolder Set olApp = Application Set olNS = olApp.GetNamespace("MAPI") Set objFolder = olNS.PickFolder ProcessFolder objFolder, "" End Sub Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder, strParentFolder As String) Dim i As Long Dim olNewFolder As Outlook.MAPIFolder Dim olTempItem As Object Set dbConn = CreateObject("ADODB.Connection") Set dbRS = CreateObject("ADODB.Recordset") 'Change 'OutlookData' to the name of your databases DSN dbConn.Open "DSN=OutlookData;" 'You will need to add your own error checking 'I am keeping it simple for this example On Error Resume Next For i = CurrentFolder.Items.Count To 1 Step -1 'Put different type items in different tables 'I have only created an email table for this example Select Case CurrentFolder.Items(i).Class Case olMail 'email is the name of the table to store emails in dbRS.Open "SELECT * FROM email", dbConn, 2, 3 'Defined Fields in table 'email' 'Folder = Text 'Sender = Text 'To = Text 'Subject = Text 'Body = Memo dbRS.AddNew dbRS("Folder") = strParentFolder & "\" & CurrentFolder.Name dbRS("Sender") = CurrentFolder.Items(i).SenderName dbRS("To") = CurrentFolder.Items(i).To dbRS("Subject") = CurrentFolder.Items(i).Subject dbRS("Body") = CurrentFolder.Items(i).Body dbRS.Update Case olAppointment Case olContact Case olNote Case olTask End Select Next For Each olNewFolder In CurrentFolder.Folders If olNewFolder.Name <> "Deleted Items" Then strParentFolder = strParentFolder & "\" & CurrentFolder.Name ProcessFolder olNewFolder, strParentFolder End If Next End Sub Function SearchForFile() As String ' Compliments of Greg Smith on the www.outlookcode.com forums On Error Resume Next Dim strBFF Dim objSHL Set objSHL = CreateObject("Shell.Application") Dim objBFF Set objBFF = objSHL.BrowseForFolder(&H0, "OpenFile", &H4031, &H11) strBFF = objBFF.ParentFolder.ParseName(objBFF.Title).Path SearchForFile = strBFF Set objBFF = Nothing Set objSHL = Nothing End Function [End Code] |
|
|
|
Steven Harvey
06-Mar-2005 10:27
The SearchForFile function is not neccessary due to DSN usage. |
|
|
|
Larry Cereghino
19-Mar-2005 23:33
Small glitch... (and I am NOT a programmer, just a computer user trying to extract messages from my outlook pst store.) When I run the code I get a error 424, "Object Required" and the module halts. Debug identifies the issue is at the subroutine "processfolder", line: frmProcessing.Label2.Caption = "Processing " & StartFolder The code runs to completion if I delete the line above but I've obviously eliminated your nice processing message subroutine. Hope you can fix it. The additional capability that I'd like to have is for the utility to export message attachments as separate files. Thanks, |
|
|
|
Larry Cereghino
20-Mar-2005 18:57
Forgot to mention -- I'm using Office/Outlook 2003 under Windows XP Pro, and running your script in a module of Microsoft Visual Basic v6.3. Larry Cereghino |
|
| Page [ 1 2 3 4 5 6 7 8 Next >> ] | ||
| Post your comment name email |
