Click here to Skip to main content
15,896,111 members
Articles / Web Development / ASP.NET

Send scheduled Reminder/Alerts by email in SharePoint

Rate me:
Please Sign up or sign in to vote.
4.87/5 (14 votes)
24 Mar 2009CPOL12 min read 594.5K   2.1K   67  
Learn how to create a SharePoint Job that queries lists and sends results via email.
using System;
using System.Collections.Generic;
using System.Text;

namespace Mullivan.SharePoint.Reminders
{
    public class RmdHourlyRecurrence : RmdRecurrence
    {
        public override string Name
        {
            get
            {
                return "Hourly";
            }
        }

        public int StartMinute
        {
            get;
            set;
        }

        public override bool CanRun(DateTime lastRun)
        {
            DateTime dtNow = DateTime.Now;

            //If never run then run
            if (lastRun.Equals(DateTime.MinValue))
                return true;

            //If there is an hour between the two then it needs to run
            if (dtNow.Subtract(lastRun).Hours > 1)
                return true;

            if (dtNow.Hour == lastRun.Hour)
            {
                //If now is greater than the start minute and the
                // last run minute is less than the start minute then return true
                if (dtNow.Minute >= this.StartMinute &&
                    lastRun.Minute < this.StartMinute)
                    return true;
            }
            else if (dtNow.Minute >= this.StartMinute)
                return true;

            return false;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions