8
Answers

Error in foreach statement cannot operate on variable of type

Hello,

I have a requirement to unread email from outlook365 using C#. For this, i am using Exchange web service (EWS). When I read emails, i am getting an error in the below line.(highlighted as bold)

foreach(EmaiMessage email in _service.FindItems(WellKnownFolderName.Inbox, new ItemView(100)))

{

}

Error : foreach statement cannot operate on variable of type 'Task<FindItemsResults<Item>>' because 'Task<FindItemsResults<Item>>' does not contain a public instance defintion for 'GetEnumerator'

DId i do anything wrong? Please suggest me.

Thanks!

Answers (8)