If you want to mark all mails as read in a specific folder in Outlook.
Here is the code-
Sub mark_all_unread_mails_as_read_in_inbox()
'Tools-> REFERENCE-> 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)
'set the specific folder name
Set oinbox = oinbox.Folders("Excel Macros")
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.