-
Jan 26th, 2018, 09:20 AM
#1
Thread Starter
New Member
I need to convert my mails to pst file. Is there any solution?
please help me out as i am in urgent need to convert my .ost to .pst file of Outlook.
Thanks
-
Jan 26th, 2018, 03:29 PM
#2
Re: I need to convert my mails to pst file. Is there any solution?
i have never needed to do this, but there appears to be several free tools that do
if you want to do it by code, i assume that, if you can open both stores, you can loop through all the messages and move whichever ones you want
i found this
Code:
'Define some constants'
'On the next line change the path to the folder that will contain the backups. Make sure the path ends with a \'
Const BACKUP_PATH = "C:\ps-scripts\Backups\"
'Create some variables
Dim strBackupFileName, objFSO, olkApp, olkSes, olkRootFolder, olkFolder, olkFolderCopy, olkBackup
'On the next line change the file name as desired'
strBackupFileName = "BU " & Year(Date) & "-" & Month(Date) & "-" & Day(Date) & ".pst"
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Connect to Outlook'
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
olkSes.Logon olkApp.DefaultProfileName
'Main routine'
On Error Resume Next
olkSes.AddStore BACKUP_PATH & strBackupFileName
Set olkBackup = olkSes.Stores.Item("Personal Folders")
olkBackup.Name = strBackupFileName
olkSes.RemoveStore olkBackup
olkSes.AddStore BACKUP_PATH & strBackupFileName
Set olkBackup = olkSes.Stores.Item(strBackupFileName)
Set olkRootFolder = olkSes.DefaultStore.GetRootFolder
For Each olkFolder In olkRootFolder.Folders
Set olkFolderCopy = olkFolder.CopyTo(olkBackup)
Next
olkSes.RemoveStore olkBackup
On Error Goto 0
'Disconnect from Outlook'
olkSes.Logoff
'Clean-up'
Set objFSO = Nothing
Set olkBackup = Nothing
Set olkRootFolder = Nothing
Set olkFolder = Nothing
Set olkFolderCopy = Nothing
Set olkSes = Nothing
Set olkApp = nothing
from https://social.msdn.microsoft.com/Fo...a?forum=isvvba
as far as i can see
it does not appear to use FSO despite creating an instance of it
it does not iterate through any sub folders, only top level folders of Personal Folders, would just need to change to a recursive procedure if you have multiple folder levels
Last edited by westconn1; Jan 26th, 2018 at 04:11 PM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|