Welcome to SharePoint CSOM hell.
You did load your List and FieldCollection, but you also have to load each Field. In fact, you have to load every SharePoint object from which you intend to get properties.
for (int i = 1; i <= 4; i++)
{
oListItem = oList.GetItemById(i);
foreach (Field field in fieldcol)
{
context.Load(field);
context.ExecuteQuery();
val = oListItem[field.Title];
if(val == null)
{
//Send e-mail
}
}
}
Edit: 8 years later, I haven't used SharePoint in a long while, but now that I look at this answer, I think it would be much better not to call context.ExecuteQuery()
in the loop. You should probably use a first loop to .Load
every field of interest, then call .ExecuteQuery
, and finally do another loop to do stuff with your newly loaded fields.
When it comes to web requests, try to be bulky, not chatty: strive to limit the amount of requests you do (as long as it makes sense, of course).