Solved

outlook script to attach pst files

Posted on 2009-04-15
6
2,198 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
  • 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 500 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
Outlook Free & Paid Tools
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now