I have designed a timer job to daily check for events and send a reminder email to registered users 1 day prior to event occurrence.
The following code fetches all event registrations for the given date. But need to fetch user email id from that foreach loop to send email. The list does not have a column for user email id, but , has 1 for user display name as :
item["Person Name"]
The following timer job code fetches events:
using (SPSite site = new SPSite(siteUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList sPList = web.Lists.TryGetList(listName);
SPQuery sPQuery = new SPQuery();
sPQuery.Query="<Where><Eq><FieldRef Name=\"Start_x0020_Time\" /><Value IncludeTimeValue='FALSE' Type=\"DateTime\"><Today OffsetDays=\"1\"/></Value></Eq></Where>";
SPListItemCollection items = sPList.GetItems(sPQuery);
if (items.Count > 0)
{
foreach (SPListItem item in items)
{
//need to call email sending function here. Has item["Person Name"] column in the list but not
//email. Is it possible to get email without adding email column to list?
}
}
}
}
}
Can u help me out to get the user email email id inside the loop to send email?