I am using Microsoft.Exchange.WebServices nuget package in VB.Net. I have the following code to read data in an email, but I cannot figure out 3 things:
1. Read only unread emails
2. Set email to read after getting data from it
3. Move email to deleted folder
Could you please help? Thank you.
1. Read only unread emails
2. Set email to read after getting data from it
3. Move email to deleted folder
Could you please help? Thank you.
Code:
Dim serverURI As New Uri("https://corpmail.....com/ews/exchange.asmx")
Dim exch As New Microsoft.Exchange.WebServices.Data.ExchangeService()
exch.Url = serverURI
exch.UseDefaultCredentials = False
exch.Credentials = New System.Net.NetworkCredential("username", "password", "domain")
Dim iv As ItemView = New ItemView(999)
iv.Traversal = ItemTraversal.Shallow
Dim inboxItems As FindItemsResults(Of Item) = Nothing
inboxItems = exch.FindItems(WellKnownFolderName.Inbox, iv)
'Dim Count As Integer = inboxItems.Count
For Each i As Item In inboxItems
MsgBox("this is" & i.Subject)
Next