QTP Forums

Full Version: I wanted to automate the process of reading new emails
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I wanted to automate the process of reading new emails.
But i am not getting the idea how to do this.
Because i am not able to recognise the object of the new incoming mail.

Please help
I think that you have to look for a property which readed mail don“t have and new mails do.

Use the object spy to discover this. Count the number of new mails using descriptive programming, and use a For or similar to read all of them.
Try to use the below code
Code:
Set olapp = createobject("outlook.application")
set inbox = olapp.getnamespace("mapi").folders

for each fold in inbox
    msgbox fold.name
    If fold.name = "Give The main Folder name" Then
        getsubfolders(fold)
    End If
    
next

    msgbox inbox.count
    sub getunreadmails(objfolder)

        set col = objfolder.items
    
        for each mail in col
            if mail.unread then
                msgbox mail.subject
                msgbox mail.sendername
                msgbox mail.body
                msgbox mail.senton
                mail.unread=false
            end if
        next

    end sub
    sub getsubfolders(objparentfolder)
        set colfolders = objparentfolder.folders
        for each objfolder in colfolders
            set objsubfolder = objparentfolder.folders(objfolder.name)
            if objfolder.name="Give the Sub Folder Name" then
                getunreadmails(objfolder)
            end if
            getsubfolders objsubfolder
        next
    end sub
Reference URL's