For your current situation you can achive results using following steps
1.Read all unread mails -do not mark them as read
2.do processing and filter mail that you want to mark as read Get unique identifier from mail such as sender ,subject (use combination for better results).get these in datatable
3.now loop datatable , use read mails activity with read mail option true and use unique filter
Imagine I have only 2 unread emails.
I will make some processing on the 1st email and if the processing has been done correctly I want immediately after mark that email as read. Only aftewards I will go to the 2nd email and process that 2nd one. And will mark afterwards that 2nd one as read, if the process on the 2nd one has been done correctly.
That invoke code activity does not work. I already saw this info and tried it last week.
āUnreadā is not a class belonging to mail message objects.
Thanks @rahatadi, but thatās really not what I want, because I initially get all the outlook messages using a given filter. Meaning that Iām unable to set a specific email from that filter group as read.
As a workaround Iām changing the status of the processed email message as āCompletedā, instead of setting it as āUnreadā.
Const olFolderDeletedItems = 3
Dim Items
Dim objSubject
Dim Arg
Set Arg = WScript.Arguments
Set objOutlook = CreateObject(āOutlook.Applicationā)
Set objNamespace = objOutlook.GetNamespace(āMAPIā)
'Set objInbox = objNamespace.GetDefaultFolder(olFolderInbox)
Set objInbox = objNamespace.Session.GetDefaultFolder(olFolderDeletedItems).Parent._
Folders(āInboxā)
Set Items = objInbox.Items
Items.Sort ā[Received]ā,True
MarkEmailUnRead(Items)
Sub MarkEmailUnRead(objItems)
For Each objItem in objItems
objSubject = Arg(0)
objsubject = objItem.subject
if Instr(objsubject,objSubject) <> 0 then
objItem.UnRead = True
objItem.Save
Exit For
end if
Next
End Sub
save above code as .vbs
and use start process with mail subject as argument