If you want to mark all mails as read in your outlook Inbox.
Here is the code -
Sub mark_all_unread_mails_as_read_in_inbox_excluding_subfolders()
'TOOLS ->Refrence -> microsoft outlook
'declare outlook objects
Dim olapp As Outlook.Application
Dim olappns As Outlook.Namespace
Dim oinbox As Outlook.Folder
Dim oitem As Outlook.MailItem
'set outlook objects
Set olapp = New Outlook.Application
Set olappns = olapp.GetNamespace("MAPI")
Set oinbox = olappns.GetDefaultFolder(olFolderInbox)
If oinbox.Items.Restrict("[UnRead] = True").Count = 0 Then
MsgBox "NO Unread Email In Inbox"
Exit Sub
End If
Do Until oinbox.Items.Restrict("[UnRead] = True").Count = 0
For Each oitem In oinbox.Items.Restrict("[UnRead] = True")
oitem.UnRead = False
Next
Loop
End Sub
Please do visit Below links to Learn Outlook VBA
ReplyDeletehttp://www.outlookcode.com
http://www.jpsoftwaretech.com/
If you came know any other Site please share with us.