Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to search mail in outlook.

Status
Not open for further replies.

vipinhcl

Programmer
Apr 21, 2010
30
0
0
US
Hi Pb Guys
I have a problem. I have to search mail in outlook with some specific subject. If search found, copy the content into database.
I have developed the code that will search the default folder Inbox with particular subject and also it is saving the data in table.

My problem is - If mail is stored in any other folder then my program will fail. I want to know how to search in all folder or any code that gives all the folder list in outlook. Is there any path in registry where all the folder list stored.

Please give me any idea.



 
If you look in the script editor (VBA code) in Outlook (ALt F11 launches it). Check out the Folders object - perhaps that will help you. Once you find out the methods on the object it's pretty straight forward to call them from within PB.

Matt

"Nature forges everything on the anvil of time
 
Thanks for the response of my query. Yes.. You are write but I took help from outlook site and This site helped me alot for working in outlook through PB.
I got the solution of my problem, yet it was not in the above outlook site but I tried myself and solved my problem. My problem was to search user defined folder from the outlook folder list. This can be at any level. My program search in all outlook folder list and return the folder object which I am searching.

/* Main Code */

OLEObject ole_outlook,ole_namespace, ole_folder
Long li_return,li_items,li_row,li_count
String ls_name,ls_classname

//6 - Inbox,3,4
ole_outlook = Create OLEObject
li_return = ole_outlook.ConnectToNewObject("outlook.application")
ole_namespace = ole_outlook.GetNameSpace("MAPI")

ole_folder = ole_namespace.GetDefaultFolder(6)//Inbox
ole_folder = ole_folder.Parent
ls_name = ole_folder.Name
li_return = ole_namespace.Folders.Count
For li_row = 1 to li_return
ole_folder = ole_namespace.Folders(li_row)
ls_name = ole_folder.Name
//VMX is the folder name which I want to search
ole_folder = uf_search_folder (ole_folder,ole_folder,"VMX")
IF IsValid(ole_folder) THEN
ls_name = ole_folder.Name
IF Upper(ls_name) = "VMX" THEN
EXIT
END IF
END IF
Next


/* uf_search_folder Function code is Here */

String ls_name
Long ll_row,ll_count,ll_folder_count
OleObject ole_folder

ls_name = as_ole_object.Name
ll_count = as_ole_object.Folders.Count
IF ll_count > 0 THEN
FOR ll_row = 1 To ll_count
ole_folder = as_ole_object.Folders(ll_row)
ll_folder_count = ole_folder.Folders.Count
ls_name = ole_folder.Name
IF Upper(ls_name) = Upper(as_data) THEN
Return ole_folder
ELSEIF ll_folder_count > 0 THEN
as_ole_object = uf_search_folder(ole_folder,as_original_object,as_data)
ls_name = as_ole_object.Name
IF Upper(as_data) = Upper(ls_name) THEN
EXIT
END IF
END IF
NEXT
ELSE
RETURN as_ole_object.Parent
END IF

IF Upper(as_data) = Upper(as_ole_object.Name) THEN
Return as_ole_object
ELSEIF ll_count <> 0 AND ll_row > ll_count THEN
Return as_original_object
ELSE
Return as_ole_object.Parent
END IF
 
Here uf_search_folder will take 2 argument as
oleobject as_ole_object
oleobject as_original_object

and will return object of oleobject type

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top