Micro Focus QTP (UFT) Forums
Issue Regarding Email content checking - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Issue Regarding Email content checking (/Thread-Issue-Regarding-Email-content-checking)



Issue Regarding Email content checking - kotaramamohana - 01-05-2011

Hi Friends,
i need to check the email notification(content) which was generated by application automatically.

i have used below mentioned code to check the email

Code:
'path of the  updating contnet in the Excel  file
strDataFileParam="D:\QTP_Razoo\"

'subject ine and sheet name
strParam="hprazoo15@sra.com] - 5 tips for making PRO2 FOR HP15 a huge success,PROPageCreation"

                                                                                    set olapp = createobject("outlook.application")
                                                                                    set inbox = olapp.getnamespace("mapi").folders
                                                    
                                                                                    Set MyExcel = createobject("Excel.application")
                                                                                    
                                                                                     Set MyFile=myExcel.workbooks.open (Mid(strDataFileParam,1,12) &"\RazooExcel.xls")
                                                                                    
                                                                                    
                                                                                    arrstrParam=Split(strParam,",")

                                                                                    for each fold in inbox
                                                                                        getsubfolders1(fold)
                                                                                    next
                                                                                     MyExcel.ActiveWorkbook.Save
                                                                                    
                                                                                    myExcel.Quit
                                                                                    Set myExcel=Nothing    
                                                                                                                            






    Sub getunreadmails1(objfolder)
                    
                                                    Set col = objfolder.items
                                                    For each mail in col
                                                    If mail.unread then
                                                        strMailSub1=mail.subject
                                                        
                                                    
                                                        If Instr(strMailSub1,arrstrParam(0))>0 Then
                
                                                        strMailBody1=mail.body
                                                        
                
                                                MyFile.worksheets(arrstrParam(1)).Cells(2, 2)= strMailBody1
                
                                                    If  MyFile.worksheets(arrstrParam(1)).Cells(2,1)= myFile.worksheets(arrstrParam(1)).Cells(2, 2) Then
                                                        MyFile.worksheets(arrstrParam(1)).Cells(2,3).value="Pass"
                                                        else
                                                        'Msgbox "Fail"
                                                         MyFile.worksheets(arrstrParam(1)).Cells(2,3).value="Fail"
                                                    End If
                
                                                    mail.unread=false
                                                    End if
                                                    end if
                                                    next
    End Sub

    
    Sub getsubfolders1(objparentfolder)
                                                [b]set colfolders = objparentfolder.folders[/b]                                                
                                                For each objfolder in colfolders
                                                
                                                    set objsubfolder = objparentfolder.folders(objfolder.name)
                                                      
                                                    if objfolder.name<>"notes" then
                                                        getunreadmails1 (objfolder)
                                                    end if
                                                    getsubfolders1(objsubfolder )
                
                                                next
    End Sub


Above code was working earlier perfectly that time we were using Xp, Outlook2000; but now I am using Windows7 and Outlook2003.
Now I am getting error as"The messaging interface has returned an unknown error. If the problem persists restart out look".

Even though after restarted outlook also same problem i am getting. I bolded the code where I got error.

Can u please share the solution if any one of know the solution.

My client is using Windows7, Outlook2007 here also its working fine.