Divakarkumar
New Member
- Joined
- Jul 31, 2020
- Messages
- 9
- Office Version
- 2016
- Platform
- Windows
Hi All,
I have made below code mark read emails to unread status in the outlook but it will work only 11 iteration then it give the data type mismatch of item.
Not sure why i am getting this error, if some help on this would great.
Sub MarkInboxMessagesAsUnread()
Dim OutlookApp As Outlook.Application
Dim OutlookNamespace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer
Dim item As Outlook.MailItem
i = 1
Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox)
For Each item In Folder.Items
item.UnRead = True
Next item
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
End Sub
I have made below code mark read emails to unread status in the outlook but it will work only 11 iteration then it give the data type mismatch of item.
Not sure why i am getting this error, if some help on this would great.
Sub MarkInboxMessagesAsUnread()
Dim OutlookApp As Outlook.Application
Dim OutlookNamespace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer
Dim item As Outlook.MailItem
i = 1
Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox)
For Each item In Folder.Items
item.UnRead = True
Next item
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
End Sub