A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

using redemption VBS



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 29th 08, 07:54 PM posted to microsoft.public.outlook.program_vba
krazymike[_2_]
external usenet poster
 
Posts: 1
Default using redemption VBS

Ok, i have this code in VBA format in an access module that runs perfectly.
What it does is extract all items in a .pst file to .msg files. I am
converting it to VBS to try to slim some overhead. (Some of the .pst files
have hundreds of thousands of mail items in them, and any clock cycles
shaved off could make hours of difference. My code runs, but the .Items
collection keeps coming back as having a count of zero. What am I doing
wrong?

option explicit
Dim j
Dim str ' , pstName As String
main()
Sub main()
Dim start
dim done
start = Now()
Dim mySession
dim olSession
set mysession = createobject("Redemption.RDOSession")
Dim s ''As RDOSession
Dim pst 'As RDOPstStore
Dim store 'As RDOStore
Dim folder 'As RDOFolder
Dim c 'As New Collection
Dim i 'As Integer
j = 0

str = chooseFile()
Set pst = mySession.LogonPstStore(str)
For Each store In mySession.Stores
Call getFolders(store.IPMRootFolder)
Next
Set mySession = Nothing
done = Now()
MsgBox "start: " & start & vbCr & "Done: " & done & vbCr & j & "
Messages processed", vbExclamation

End Sub

Sub getFolders(fs) 'As RDOFolder)
On Error Resume Next
Dim f 'As RDOFolder
Dim m 'As RDOMail
For Each f In fs.Folders
For Each m In f.Items ' This where the count comes into play
Call getMsgs(m)
Next

Call getFolders(f) ' recurse through the folder tree
Next
End Sub

Sub getMsgs(m) ' As RDOMail)

dim fname 'As String
fname = "C:\tempy\" & m.entryid & ".msg"
msgbox fname
m.SaveAs (fname)
j = j + 1

End Sub

Function chooseFile() ' As String
dim objFSO
dim initfso
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")

ObjFSO.Filter = "PST Files|*.pst"

ObjFSO.FilterIndex = 1

ObjFSO.InitialDir = "c:\psts"

InitFSO = ObjFSO.ShowOpen

If InitFSO = False Then
Wscript.Echo "Script Error: Please select a file!"
Wscript.Quit
Else
' Wscript.Echo "You selected the file: " & ObjFSO.FileName
End If

chooseFile = initfso

End Function


Ads
  #2  
Old May 29th 08, 08:15 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default using redemption VBS

Leaving aside your code, running in VBA will be faster than running in
VBScript, so I'd abandon that idea to begin with.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"krazymike" wrote in message
...
Ok, i have this code in VBA format in an access module that runs
perfectly. What it does is extract all items in a .pst file to .msg files.
I am converting it to VBS to try to slim some overhead. (Some of the .pst
files have hundreds of thousands of mail items in them, and any clock
cycles shaved off could make hours of difference. My code runs, but the
.Items collection keeps coming back as having a count of zero. What am I
doing wrong?

option explicit
Dim j
Dim str ' , pstName As String
main()
Sub main()
Dim start
dim done
start = Now()
Dim mySession
dim olSession
set mysession = createobject("Redemption.RDOSession")
Dim s ''As RDOSession
Dim pst 'As RDOPstStore
Dim store 'As RDOStore
Dim folder 'As RDOFolder
Dim c 'As New Collection
Dim i 'As Integer
j = 0

str = chooseFile()
Set pst = mySession.LogonPstStore(str)
For Each store In mySession.Stores
Call getFolders(store.IPMRootFolder)
Next
Set mySession = Nothing
done = Now()
MsgBox "start: " & start & vbCr & "Done: " & done & vbCr & j & "
Messages processed", vbExclamation

End Sub

Sub getFolders(fs) 'As RDOFolder)
On Error Resume Next
Dim f 'As RDOFolder
Dim m 'As RDOMail
For Each f In fs.Folders
For Each m In f.Items ' This where the count comes into play
Call getMsgs(m)
Next

Call getFolders(f) ' recurse through the folder tree
Next
End Sub

Sub getMsgs(m) ' As RDOMail)

dim fname 'As String
fname = "C:\tempy\" & m.entryid & ".msg"
msgbox fname
m.SaveAs (fname)
j = j + 1

End Sub

Function chooseFile() ' As String
dim objFSO
dim initfso
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")

ObjFSO.Filter = "PST Files|*.pst"

ObjFSO.FilterIndex = 1

ObjFSO.InitialDir = "c:\psts"

InitFSO = ObjFSO.ShowOpen

If InitFSO = False Then
Wscript.Echo "Script Error: Please select a file!"
Wscript.Quit
Else
' Wscript.Echo "You selected the file: " & ObjFSO.FileName
End If

chooseFile = initfso

End Function



  #3  
Old May 30th 08, 11:40 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default using redemption VBS

For *all* folders? Or just RDOStore.IPMRootFolder (which usually has no
messages)?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"krazymike" wrote in message
...
Ok, i have this code in VBA format in an access module that runs
perfectly. What it does is extract all items in a .pst file to .msg files.
I am converting it to VBS to try to slim some overhead. (Some of the .pst
files have hundreds of thousands of mail items in them, and any clock
cycles shaved off could make hours of difference. My code runs, but the
.Items collection keeps coming back as having a count of zero. What am I
doing wrong?

option explicit
Dim j
Dim str ' , pstName As String
main()
Sub main()
Dim start
dim done
start = Now()
Dim mySession
dim olSession
set mysession = createobject("Redemption.RDOSession")
Dim s ''As RDOSession
Dim pst 'As RDOPstStore
Dim store 'As RDOStore
Dim folder 'As RDOFolder
Dim c 'As New Collection
Dim i 'As Integer
j = 0

str = chooseFile()
Set pst = mySession.LogonPstStore(str)
For Each store In mySession.Stores
Call getFolders(store.IPMRootFolder)
Next
Set mySession = Nothing
done = Now()
MsgBox "start: " & start & vbCr & "Done: " & done & vbCr & j & "
Messages processed", vbExclamation

End Sub

Sub getFolders(fs) 'As RDOFolder)
On Error Resume Next
Dim f 'As RDOFolder
Dim m 'As RDOMail
For Each f In fs.Folders
For Each m In f.Items ' This where the count comes into play
Call getMsgs(m)
Next

Call getFolders(f) ' recurse through the folder tree
Next
End Sub

Sub getMsgs(m) ' As RDOMail)

dim fname 'As String
fname = "C:\tempy\" & m.entryid & ".msg"
msgbox fname
m.SaveAs (fname)
j = j + 1

End Sub

Function chooseFile() ' As String
dim objFSO
dim initfso
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")

ObjFSO.Filter = "PST Files|*.pst"

ObjFSO.FilterIndex = 1

ObjFSO.InitialDir = "c:\psts"

InitFSO = ObjFSO.ShowOpen

If InitFSO = False Then
Wscript.Echo "Script Error: Please select a file!"
Wscript.Quit
Else
' Wscript.Echo "You selected the file: " & ObjFSO.FileName
End If

chooseFile = initfso

End Function




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Redemption & Outlook glm Outlook and VBA 1 May 17th 08 05:19 PM
Error 0 with Redemption...huh? Dewey Add-ins for Outlook 2 October 24th 07 12:19 AM
inconsistent in Redemption Vadivel Outlook and VBA 10 April 25th 06 06:12 PM
Redemption Christoph Add-ins for Outlook 5 March 6th 06 03:26 PM
Redemption MAPITable Dmitry Streblechenko Add-ins for Outlook 1 January 12th 06 04:09 AM


All times are GMT +1. The time now is 06:43 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.