Click here to Skip to main content
15,892,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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
VB
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
VB
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900