Solved

outlook script to attach pst files

Posted on 2009-04-15
6
2,273 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 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Active Directory Account getting mysteriously locked 13 80
exchange 13 25
Launch Outlook minimized 6 35
Exchange 2013 - Using Thunderbird as client 3 29
What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
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…

730 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