Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The operation failed. An object could not be found.
#1
Not Solved
Hi Friends,

I have an issue in the email checking, and i have given the error below. And has also attached the code i used. If i am not declaring the variables its working perfectly, if i use this in the framework it throws error. Please help me to resolve this issue.

---------
Error:
---------
The operation failed. An object could not be found.

Line (63):
Code:
"set objsubfolder = objparentfolder.folders(objfolder.name)".

----------------------------------------

Code:
Option Explicit
Dim olapp,inbox,fold,colfolders,objfolder,objsubfolder,objparentfolder,mail,col,strMailSub1,strMailSub2,strMailBody1,strMailBody2,strMailBody3


Call fnResetPassword()

Public Function fnResetPassword()
    
        
    set olapp = createobject("outlook.application")
    set inbox = olapp.getnamespace("mapi").folders
    
    for each fold in inbox
    'msgbox fold.name
    'If fold="Razoo Mails" Then
        getsubfolders(fold)
    'End If
    next
    
    'msgbox inbox.count

End Function    
        
    sub getunreadmails(objfolder)
    
    set col = objfolder.items
    for each mail in col
    If mail.unread then
         strMailSub1=mail.subject
      strMailSub2=split(strMailSub1,"-")
        If Trim(strMailSub2(1))="Password reset request" Then
        
        'datatable.SetCurrentRow i
    'msgbox mail.subject
    
    'datatable.Value("Subject","Global")=mail.subject
    'msgbox mail.sendername
    'msgbox mail.body
    
    strMailBody1=mail.body
    strMailBody2=split(strMailBody1,"http://")
    strMailBody3=split(Trim(strMailBody2(1)),"edit")
    'Datatable.Value("Expected","SubDriver[SubDriver]")=Trim(strMailBody3(0))&"edit"
    strResetUrl=Trim(strMailBody3(0))&"edit"
    'Msgbox "http//" &z(0) &"/edit"
    msgbox strResetUrl
    
    'msgbox mail.senton
    mail.unread=false
    End if
    end if
    next
    end sub


    
    sub getsubfolders(objparentfolder)
            set colfolders = objparentfolder.folders
            'msgbox colfolders.count
            For each objfolder in colfolders
                    'msgbox objfolder.name
                set objsubfolder = objparentfolder.folders(objfolder.name)
                   msgbox objsubfolder.name
                if objfolder.name<>"notes" then
                    getunreadmails(objfolder)
                end if
                getsubfolders objsubfolder
            next
    end sub




Regards,
Ram
Reply
#2
Not Solved
Hi,

Can you try setting the initialized objects to 'Nothing' at the end of the sub routines, when they are of no use. I had same error once and it worked for me. I think without the explicit declaration the variables are created and destroyed within the scope of the function, so you are not getting the error when you are not using 'Option explicit'

Let me know if it helps.

Cheers
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  "Action was not found" error. What to do? ttralor 2 6,094 05-04-2017, 03:54 PM
Last Post: Ankur
  Failed to run Batch with MTM in UFT 11.5 mayankchauhan 1 2,890 09-19-2014, 05:32 PM
Last Post: vishalshah.qa
  Highlight the Found text in Word/notepad Sivakumar2186@gmail.com 2 3,719 10-21-2013, 06:31 PM
Last Post: BadrinarayananR
  I found my way to set up QTP, but is it a good way? ttralor 1 2,623 01-21-2013, 09:35 AM
Last Post: Ankesh
  Object not found Laura_F 9 6,967 02-01-2012, 04:26 PM
Last Post: shivu.impu

Forum Jump:


Users browsing this thread: 2 Guest(s)