Problem in search folder,

S

Srinivas Remala

HI all,

I am software test engineer working Outlook based project,
Object by using ruby script is user requested folder should select on
already opened outlook.

I am able to get this functionality on new outlook launch but I want
these functionality on existed outlook.

I am posting my script please help me according that.

require 'win32ole'
olapp = WIN32OLE::new("outlook.Application")
class OutlookConst
end # load Outlook OLE constants

WIN32OLE.const_load(olapp, OutlookConst)

mymapi = olapp.GetNameSpace("MAPI") #Get the MAPI Object
puts "Enter the name of the folder that you want to focus:"
foldername=STDIN.gets
#Get the folder name

foldername=foldername.strip
foldername=foldername.upcase

#Remove Leading/Trailing Spaces and convert it to the uppercase

myfolder=0
#Initialization

folders = mymapi.Folders

# Get the Base folder collection

folders.each {
| folder |

if(folder.Name.upcase==foldername)
myfolder=folder
end

subfolder=folder.Folders

subfolder.each {
| folder1 |
if(folder1.Name.upcase==foldername)
myfolder=folder1
end

sub2folder=folder1.Folders


sub2folder.each{
|folder2|
if(folder2.Name.upcase==foldername)
myfolder=folder2
end


}



}

}


if(myfolder==0)
puts "No such folder found"
else
puts "\"myfolder\" is the handle for the required folder "
myfolder.Display
end


#olapp.quit
#olapp=nil
GC.start


Thanking You
Srinivas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top