Hi all,
I have a contact database, and i'm trying to generate an email reminder to "Owners" of items they have flagged for follow up. It could be multiple items from multiple contacts per owner and could be for many owners. I am struggling with the concept to send a group of follow ups to the owners individually.
All the follow ups are recorded in a history table. How would i group them so my email routine would send out a listing to each owner?
The concept statement would be:
- For each owner that has a follow up, send them a list of all contact follow ups due today (or past due)
Should i group them in SQL returning multiple tables for each user, then with simple SqlDataReader use NextResult, or can i group them in code somehow from a single resultset?
my single SQL results table
I have a contact database, and i'm trying to generate an email reminder to "Owners" of items they have flagged for follow up. It could be multiple items from multiple contacts per owner and could be for many owners. I am struggling with the concept to send a group of follow ups to the owners individually.
All the follow ups are recorded in a history table. How would i group them so my email routine would send out a listing to each owner?
The concept statement would be:
- For each owner that has a follow up, send them a list of all contact follow ups due today (or past due)
Should i group them in SQL returning multiple tables for each user, then with simple SqlDataReader use NextResult, or can i group them in code somehow from a single resultset?
my single SQL results table
Code:
SELECT hist.ContactID, hist.HistSchedule, hist.HistNotes,
dbo.ContactFullName(hist.ContactID) AS ContactName,
dbo.UserNameByID(contact.ContactOwner,1) AS Owner,
dbo.UserEmailByID(contact.ContactOwner) AS OwnerEmail
FROM tblHistory hist
LEFT JOIN tblContact contact ON hist.ContactID = contact.ContactID
WHERE hist.HistSchedule IS NOT NULL
AND hist.FollowUpComplete = 0
AND hist.HistSchedule < GetDate()
ORDER BY contact.ContactOwner, hist.HistSchedule
Code:
233 2010-01-27 Contact Request: From Web Customer R Adam R adamr@domain.com
237 2009-11-13 Send quote for stuff Keith G Lauren B laurenb@domain.com