?
Solved

outlook script to attach pst files

Posted on 2009-04-15
6
Medium Priority
?
2,340 Views
Last Modified: 2012-05-06
I'm looking for some code that could help me in getting this job done; Import all pst files available in a shared folder into outlook. I have 300 pst files that I need to attach to outlook for indexing.

thanks in advance.
0
Comment
Question by:stasila2010
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 24150440
Hi, stasila2010.

What version of Outlook?  By "import" you mean you want the PSTs connected to Outlook?  You aren't looking to actually import their contents into another PST or your mailbox, right?
0
 

Author Comment

by:stasila2010
ID: 24150460
I'm using outlook 2003 right now and If I need to I can use 2007. yes I just want to connect them to outlook all at once. by default I can only select one and then another one and so on.

thanks for your help
0
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 24153388
Here's the code.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor
10. Run the macro
Sub OpenPSTs()
    Dim objFSO As Object, objFolder As Object, objFile As Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Change the folder path on the next line'
    Set objFolder = objFSO.GetFolder("C:\SomeFolderName")
    For Each objFile In objFolder.Files
        If LCase(objFSO.GetExtensionName(objFile.Name)) = "pst" Then
            Outlook.Application.Session.AddStore objFile.Path
        End If
    Next
    Set objFolder = Nothing
    Set objFSO = Nothing
    MsgBox "Done"
End Sub

Open in new window

0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:stasila2010
ID: 24157602
thank you very much for your VB script. I did worked but only added around 10 PST files to my outlook and then ended with Run-time error '-901758971 (ca404005)':
0
 

Author Comment

by:stasila2010
ID: 24159971
got it. your script works perfect.
thanks a lot.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24160352
You're welcome.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question