views:

962

answers:

1

I am writing a C# code to find all of our SharePoint Sites that have emails contained in the Email List page. It appears that some of our email messages are SPListItem.ContentType.Name = "Message" and some of our email messages are SPListItem.ContentType.Name = "Discussion"

Aside from the confusion, this is forcing my to cycle through mylist.Folders and mylist.Items in two separate loops, so that I don't miss any of the emails.

Is this normal? Any idea why this could be happening? There are threads that contains messages of both types.

A: 

Can you use a CAML query to retrieve the items from the list, like so:

<Where>
  <Or>
    <Eq>
      <FieldRef Name='ContentType'>
      <Value Type='Text'>Message</Value>
    </Eq>
    <Eq>
      <FieldRef Name='ContentType'>
      <Value Type='Text'>Discussion</Value>
    </Eq>
  </Or>
</Where>

use this in an SPQuery like so:

SPQuery qry = new SPQuery();
qry.Query = "CAML SHOWN ABOVE";

list.GetItems(qry);
Colin