I'm a beginner at Sharepoint development and C# in general, although I have been coding in other languages for many years.
I've been working through the example in this chapter but couldn't get it to send the notification email. After spending a couple of hours messing around with the code and writing debug messages out to the Windows event log (can't debug using MS Visual C# Express), I found out that the line in the LoadHiringManagersEmail method:
SPItem jobItem = jobList.Items[jobValue.LookupId];
was throwing the error "Specified argument was out of the range of valid values". The line to retrieve the correct Department list item was doing exactly the same thing. My debug messages were showing that it was definitely retrieving the correct Job Title from the Applicant item, but it was throwing an error trying to retrieve the corresponding Job item from the job list.
I eventually found that using:
SPItem jobItem = jobList.Items.GetItemById(jobValue.LookupId];
did work. I rewrote the code so many times that I don't think it can have been a typo or a copy error, and I'm pretty confident that I set up my Department and Jobs lists correctly.
Can anyone explain to me why using the
method worked, when using
I'd appreciate any comments or pointers as I'm not satisfied with just having got it working - I need to understand why in order to really learn.
Platform is WSS 3.0 running on Windows Server 2003 R2 in a HyperV terminal.