Monday, August 22, 2011

Fetching All Replies/Messages of a DISCUSSION List/TOPIC

string ite = string.Empty;
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Emails"];
//Get the topic. (you can use other ways to get the topic)
SPFolder t = list.GetItemById(9).Folder;
SPQuery q = new SPQuery();
q.Folder = t;
SPListItemCollection res = list.GetItems(q);
foreach (SPListItem item1 in res)
{

object ss = item1["Body"];

object s1 = item1["EmailFrom"];
object s2 = item1["Modified"];


ite += " " + s1 + " " + ss + " " + s2.ToString() ;
for (int i = 0; i < item1.Attachments.Count; i++)
{
Response.Write("Attachment Url " + item1.Attachments.UrlPrefix + item1.Attachments + "
");
}



// Read body of attachment

Response.Write("Body: " + item1.Fields["Body"].GetFieldValueAsText(item1["Body"]) + "");
}
Response.Write(ite);

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

Different #memories in #free #command in #linux

The   free   command in Linux is a powerful tool for monitoring memory usage on your system. It provides information about various types of ...