Outlook and command line

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Does anyone knows a way to open a PST file using outlook command line ?
Ideally this procédure woud permanently link the PST to the Windows
Messaging Subsystem.

I guess it is a somewhat strange question.
Might be another solution maybe : act with a PRF or edit the Windows
Messaging Subsystem ?

My concern is that we plan to migrate aroud 1500 users, each one has a 1 or
more PST file linked to his outlook profile. This migration would collect
PST's but will gather them in a single new location so that profile migration
would be unproper.

Thanks for your help.

Xho
 
A .prf file would be a good solution, since it would update the mail profile with the additional .pst file as Outlook opens.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
That's what I instinctively intend to do.

My technical target would be to :

- Use a standard PRF to generate an Outlook profile
- Browse the defaut foler for PST storage to list all PST files within this
folder
- Generate one PRF (or one PRF per PST) that would contains PRST's new file
references. Is there any specific format to register PST among a PRF file ?

Are .PAB still used under outlook 2003 ? That's out of scope :-)

Xho

"Sue Mosher [MVP-Outlook]" a écrit :
 
Are .PAB still used under outlook 2003 ? That's out of scope :-)

PAB files are supported in 2003 for backwards compatibility but hardly anyone uses them.
Is there any specific format to register PST among a PRF file ?

Yes, just generate a .prf file with a .pst in it from CIW/CMW and you'll see the right format. You can also take a look at listing 4.5 from my Configuring book, which searches %appdata%\Microsoft\Outlook for .pst files, adds them to an existing .prf file, and saves the result as a new ..prf file. It ignores .pst files from IMAP accounts.

Listing 4.5 [page 154]
======================

Dim userPath
Call AddPSTsToPRF( _
"C:\Program Files\Microsoft Office\" & _
"Office11\basic new Exchange.prf", _
"installme.prf")

Sub AddPSTsToPRF(prfPath, prfOutputFile)
Const FORREADING = 1
Const FORWRITING = 2

arrPST = FindPSTs()
For i = 0 To UBound(arrPST)
strServiceList = strServiceList & vbCrLf & _
"ServicePST" & i & _
"=Unicode Personal Folders"
strServices = strServices & vbCrLf & _
"[ServicePST" & i & "]" & _
vbCrLf & "UniqueService=No" & _
vbCrLf & _
"PathToPersonalFolders=" & _
userPath & arrPST(i) & vbCrLf
Next

If Len(strServiceList) > 2 Then
strServiceList = Mid(strServiceList, 3)
strServices = Mid(strServices, 3)

Set fso = _
CreateObject("Scripting.FileSystemObject")
Set prfFile = fso.GetFile(prfPath)
If Not prfFile Is Nothing Then
Set ts = _
prfFile.OpenAsTextStream(ForReading)
prfContents = ts.ReadAll
prfContents = Replace(prfContents, _
"[Service List]", _
"[Service List]" & _
vbCrLf & strServiceList, _
1, 1, vbTextCompare)
prfContents = Replace(prfContents, _
";[ServiceX]", _
strServices & vbCrLf & _
";[ServiceX]", _
1, 1, vbTextCompare)
ts.Close

Set ts = fso.CreateTextFile(userPath & _
prfOutputFile, True)
ts.Write prfContents
ts.Close
End If
End If
End Sub

Function FindPSTs()
' get path to default location for PST files
Set WshShell = CreateObject("WScript.Shell")
userPath = WshShell.expandenvironmentstrings _
("%userprofile%") & _
"\Local Settings\Application Data" & _
"\Microsoft\Outlook\"

Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(userPath)

For Each myFile In fld.Files
If Right(UCase(myFile.Name), 4) = ".PST" Then
days = DateDiff("d", _
myFile.DateLastModified, Date)
If days < 31 Then
If Left(myFile.Name, 18) <> _
"SharePoint Folders" Then
strFileList = strFileList & ";" & _
myFile.Name
End If
End If
End If
Next
If strFileList <> "" Then
strFileList = Mid(strFileList, 2)
FindPSTs = Split(strFileList, ";")
End If
End Function

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Xhork said:
That's what I instinctively intend to do.

My technical target would be to :

- Use a standard PRF to generate an Outlook profile
- Browse the defaut foler for PST storage to list all PST files within this
folder
- Generate one PRF (or one PRF per PST) that would contains PRST's new file
references. Is there any specific format to register PST among a PRF file ?

Are .PAB still used under outlook 2003 ? That's out of scope :-)

Xho

"Sue Mosher [MVP-Outlook]" a écrit :
A .prf file would be a good solution, since it would update the mail profile with the additional .pst file as Outlook opens.
 
Looks great.
I will test it ASAP :-)

And I wil llet you know of course

Xho

"Sue Mosher [MVP-Outlook]" a écrit :
Are .PAB still used under outlook 2003 ? That's out of scope :-)

PAB files are supported in 2003 for backwards compatibility but hardly anyone uses them.
Is there any specific format to register PST among a PRF file ?

Yes, just generate a .prf file with a .pst in it from CIW/CMW and you'll see the right format. You can also take a look at listing 4.5 from my Configuring book, which searches %appdata%\Microsoft\Outlook for .pst files, adds them to an existing .prf file, and saves the result as a new ..prf file. It ignores .pst files from IMAP accounts.

Listing 4.5 [page 154]
======================

Dim userPath
Call AddPSTsToPRF( _
"C:\Program Files\Microsoft Office\" & _
"Office11\basic new Exchange.prf", _
"installme.prf")

Sub AddPSTsToPRF(prfPath, prfOutputFile)
Const FORREADING = 1
Const FORWRITING = 2

arrPST = FindPSTs()
For i = 0 To UBound(arrPST)
strServiceList = strServiceList & vbCrLf & _
"ServicePST" & i & _
"=Unicode Personal Folders"
strServices = strServices & vbCrLf & _
"[ServicePST" & i & "]" & _
vbCrLf & "UniqueService=No" & _
vbCrLf & _
"PathToPersonalFolders=" & _
userPath & arrPST(i) & vbCrLf
Next

If Len(strServiceList) > 2 Then
strServiceList = Mid(strServiceList, 3)
strServices = Mid(strServices, 3)

Set fso = _
CreateObject("Scripting.FileSystemObject")
Set prfFile = fso.GetFile(prfPath)
If Not prfFile Is Nothing Then
Set ts = _
prfFile.OpenAsTextStream(ForReading)
prfContents = ts.ReadAll
prfContents = Replace(prfContents, _
"[Service List]", _
"[Service List]" & _
vbCrLf & strServiceList, _
1, 1, vbTextCompare)
prfContents = Replace(prfContents, _
";[ServiceX]", _
strServices & vbCrLf & _
";[ServiceX]", _
1, 1, vbTextCompare)
ts.Close

Set ts = fso.CreateTextFile(userPath & _
prfOutputFile, True)
ts.Write prfContents
ts.Close
End If
End If
End Sub

Function FindPSTs()
' get path to default location for PST files
Set WshShell = CreateObject("WScript.Shell")
userPath = WshShell.expandenvironmentstrings _
("%userprofile%") & _
"\Local Settings\Application Data" & _
"\Microsoft\Outlook\"

Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(userPath)

For Each myFile In fld.Files
If Right(UCase(myFile.Name), 4) = ".PST" Then
days = DateDiff("d", _
myFile.DateLastModified, Date)
If days < 31 Then
If Left(myFile.Name, 18) <> _
"SharePoint Folders" Then
strFileList = strFileList & ";" & _
myFile.Name
End If
End If
End If
Next
If strFileList <> "" Then
strFileList = Mid(strFileList, 2)
FindPSTs = Split(strFileList, ";")
End If
End Function

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Xhork said:
That's what I instinctively intend to do.

My technical target would be to :

- Use a standard PRF to generate an Outlook profile
- Browse the defaut foler for PST storage to list all PST files within this
folder
- Generate one PRF (or one PRF per PST) that would contains PRST's new file
references. Is there any specific format to register PST among a PRF file ?

Are .PAB still used under outlook 2003 ? That's out of scope :-)

Xho

"Sue Mosher [MVP-Outlook]" a écrit :
A .prf file would be a good solution, since it would update the mail profile with the additional .pst file as Outlook opens.

Hello,

Does anyone knows a way to open a PST file using outlook command line ?
Ideally this procédure woud permanently link the PST to the Windows
Messaging Subsystem.

I guess it is a somewhat strange question.
Might be another solution maybe : act with a PRF or edit the Windows
Messaging Subsystem ?

My concern is that we plan to migrate aroud 1500 users, each one has a 1 or
more PST file linked to his outlook profile. This migration would collect
PST's but will gather them in a single new location so that profile migration
would be unproper.

Thanks for your help.

Xho
 
Back
Top