Click here to Skip to main content
15,894,106 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 593.6K   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;
using Mullivan.SharePoint;
using System.IO;
using System.Web;

namespace Mullivan.SharePoint.Remote
{
    public class SPItem
    {
        private SPContentType _contentType;

        internal SPItem(SPContentType contentType, bool isNew)
        {
            _contentType = contentType;
            this.Properties = new Dictionary<string, string>();
            this.IsNew = isNew;
        }

        internal bool IsNew
        {
            get;
            set;
        }

        public SPContentType ContentType
        {
            get { return _contentType; }
        }

        public Dictionary<string, string> Properties
        {
            get;
            set;
        }

        public byte[] Binary
        {
            get;
            set;
        }

        public int Id
        {
            get;
            set;
        }

        public string Name
        {
            get;
            set;
        }

        public string Extension
        {
            get;
            set;
        }

        public string Folder
        {
            get;
            set;
        }

        public string Version
        {
            get;
            set;
        }

        public bool CheckedOut
        {
            get;
            set;
        }

        public string CheckedoutUser
        {
            get;
            set;
        }

        public string[] AttachmentUrls
        {
            get;
            set;
        }

        public string GetUrl()
        {
            string docUrl = string.Empty;

            docUrl = this.ContentType.List.FullUri.TrimEnd('/');
            docUrl += "/";

            if (!string.IsNullOrEmpty(this.Folder))
                docUrl += this.Folder.Trim('/');

            if (this.ContentType.List.BaseType == SPListBaseType.DocumentLibrary)
            {
                if (string.IsNullOrEmpty(this.Name))
                    this.Name = Guid.NewGuid().ToString().Trim('{', '}');
                    
                docUrl += this.Name;
                docUrl += ".";

                if (string.IsNullOrEmpty(this.Extension))
                    throw new Exception("Error generating the item's Url. The Extension property must be set when the item belongs to a Document Library.");

                docUrl += this.Extension;
            }
            else
            {
                if (this.Id < 1)
                    throw new Exception("Error generating the item's Url. The ID property must be set when the item belongs to a List.");

                docUrl += this.Id.ToString() + "_.000";
                
            }

            return HttpUtility.UrlPathEncode(docUrl);
        }
    }
}

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