Hi,
Dim olFolderInbox, iTotalMails, sSubject
olFolderInbox = 6 : sSubject = ""
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
'Create reference to Inbox Folder
Set oInbox = objNamespace.GetDefaultFolder(olFolderInbox)
'Find all items in the Inbox Folder
Set oAllMails = oInbox.Items
iTotalMails = oAllMails.Count
'Loop through the mail items
For i=1 to iTotalMails
'Check if the mail is UnRead or not
If oAllMails(i).UnRead = True Then
sSubject = sSubject & oAllMails(i).Subject & vbCrLf
End If
Next
'Display the results
msgbox sSubject
On Tuesday, 5 May 2015 22:31:33 UTC+5:30, ankit garg wrote:
>
> Hi,
>
> I have 2 accounts configured in my outlook.Need to read mails from second
> email account.I have below code which can check emails(inbox folder) from
> first account.Can anyone please help me out.
>
>
> *Find out the list of all unread emails in Outlook Inbox*
>
>
> Dim InboxFolder=6
> Set ObjOUtlook = CreateObject("Outlook.Application")
> Set objNamespace = objOutlook.GetNamespace("MAPI")
> Set oInbox = objNamespace.GetDefaultFolder(InboxFolder)
> Set oAllMails = oInbox.Items
>
>
> iTotalMails = oAllMails.Count // Count the total NUmber of Read and
> Unread Mail in inbox folder.
>
> For i=1 to iTotalMails
> 'Check if the mail is UnRead or not
> If oAllMails(i).UnRead = True Then
> sSubject = sSubject & oAllMails(i).Subject & vbCrLf
> End If
> Next
>
> msgbox sSubject
>
>
--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
---
You received this message because you are subscribed to the Google Groups "QTP
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.