In order to programmatically create a new view in SP2007, you need to get a reference to the list, get the collection of available views, setup a filter –if needed, and create a new collection of fields to include in the new view.
Use the following example as a how-to.
SPList workList = web.Lists[“Work List”]; //reference to the list
SPViewCollection wlViews = workList.Views; //collection of available views
System.Collections.Specialized.StringCollection scViewFields = new System.Collections.Specialized.StringCollection(); //collection of fields to display in new view
string filter = “<Where><Geq><FieldRef Name=\”ReminderDate\”/><Value Type=\”DateTime\”><Today /></Value></Geq></Where>”; //CAML Query to filter items in/out of the view
scViewFields.Add(“Work Item Id”); //add fields to view
scViewFields.Add(“LinkTitle”); //title with Context menu to edit the item
scViewFields.Add(“Date Published”);
pqViews.Add(“Overdue Queries”, scViewFields, filter, 8, true, false); //add view to collection of views