Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VBScript Outlook
Hi everyone,
 
I wrote a script which can find the .apk and import aoutomaticly in outlook.
 
But i have a problem. i can set 4 path folder. And the script look path folders and find the apk.
 
But when this script can find an .apk folders, the program finish.
 
This script doesn't look another path.
 
On Error Resume Next
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objnet = CreateObject("wscript.network")
	Set olkApp = CreateObject("Outlook.Application") 
	Set objFolder = objFSO.GetFolder("C:\Documents and Settings\" & objnet.UserName & "\")
	Set objFolder = objFSO.GetFolder("C:\Documents and Settings\" & objnet.UserName & "\Local Settings\Application Data\Microsoft\Outlook")
	Set objFolder = objFSO.GetFolder("C:\Documents and Settings\" & objnet.UserName & "\Belgelerim\mail")
	Set objFolder = objFSO.GetFolder("C:\Documents and Settings\" & objnet.UserName & "\AppData\Local\Microsoft\Outlook")
	Set objFolder = objFSO.GetFolder("C:\Documents and Settings\" & objnet.UserName & "\Belgelerim\mailbox")
     For Each objFile in objFolder
		 If LCase(objFSO.GetExtensionName(objFile.Name)) = "pst" Then
			olkApp.Session.AddStore objFile.Path
	 End If
Next
MsgBox "Done"
 
For example, this script find the path .apk folder
(Set objFolder = objFSO.GetFolder("C:\Documents and Settings\" & objnet.UserName & "\")) 
And doesn't look another paths.
 
How to solve this problem.
 
Thanks for any helping.
Posted 19-Sep-11 8:54am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The way your code is now only the last folder is used, with each Set objFolder statement you are overwriting the previous value. So in effect only the files in the folder from the statement
Set objFolder = objFSO.GetFolder("C:\Documents and Settings\" & objnet.UserName & "\Belgelerim\mailbox")
are searched.
 
In order to look in all the folders execute the file searching code
For Each objFile in objFolder
	If LCase(objFSO.GetExtensionName(objFile.Name)) = "pst" Then
		olkApp.Session.AddStore objFile.Path
	End If
Next
for each set objFolder statement.
 
Note: Instead of repeating the code several times you should place it in a separate procedure.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 19 Sep 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100