I was not able to do something a little more elaborate with my timer job so I decided to check if something basic works. So I tried the code below - but it keeps giving me this error - why?
UPDATE
Error text is: ArgumentOutOfRangeException was unhandled by user code - Specified argument was out of the range of valid values.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace AlertAudit
{
public class AlertMailer : SPJobDefinition {
public AlertMailer()
: base() {
}
public AlertMailer(string alertName, SPWebApplication webApplication)
: base(alertName, webApplication, null, SPJobLockType.ContentDatabase)
{
this.Title = "Alert Mailerv1";
}
public override void Execute(Guid contentDbId)
{
base.Execute(contentDbId);
// get a reference to the current site collection's content database
SPWebApplication webApplication = this.Parent as SPWebApplication;
SPContentDatabase contentDb = webApplication.ContentDatabases[contentDbId];
using (SPWeb web = new SPSite("http://myRootSite/").OpenWeb())
{
foreach (SPList list in web.Lists)
{
Console.WriteLine(list.Title);
}
}
}
}
}
thanks,
KS