Click here to Skip to main content
15,884,537 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 590.1K   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 System.Net;
using System.Xml.Serialization;
using Mullivan.Serialization;
using Mullivan.Cryptography;

namespace Mullivan.Security
{
    public class SerializableCredential : IXmlSerializable
    {
        private string _userName = string.Empty;
        private string _password = string.Empty;
        private string _domain = string.Empty;
        private const string _INITVECT = "noau8g348OIF@E*00(_!)@(*#&$303";
        private const string _ENCKEY = "alkjsd*(@()*_)(*$poqawjqIH@IUH";
        
        public string UserName
        {
            get
            {
                return _userName;
            }
            set
            {
                _userName = value;
            }
        }

        public string Password
        {
            get
            {
                return _password;
            }
            set
            {
                _password = value;
            }
        }

        public string Domain
        {
            get
            {
                return _domain;
            }
            set
            {
                _domain = value;
            }
        }

        public NetworkCredential GetCredential()
        {
            return new NetworkCredential(this.UserName, this.Password, this.Domain);
        }

        #region IXmlSerializable Members

        public System.Xml.Schema.XmlSchema GetSchema()
        {
            return null;
        }

        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;

            reader.ReadStartElement();

            reader.ReadStartElement("UserName");
            _userName = GenericSerializer.Deserialize<string>(reader);
            reader.ReadEndElement();
            reader.ReadStartElement("Password");
            _password = Encryption.Decrypt(GenericSerializer.Deserialize<string>(reader), _INITVECT, _ENCKEY);
            reader.ReadEndElement();
            reader.ReadStartElement("Domain");
            _domain = GenericSerializer.Deserialize<string>(reader);
            reader.ReadEndElement();

            reader.ReadEndElement();
        }

        public void WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("UserName");
            GenericSerializer.Serialize<string>(_userName);
            writer.WriteEndElement();
            writer.WriteStartElement("Password");
            GenericSerializer.Serialize<string>(Encryption.Encrypt(_password,_INITVECT, _ENCKEY));
            writer.WriteEndElement();
            writer.WriteStartElement("Domain");
            GenericSerializer.Serialize<string>(_domain);
            writer.WriteEndElement();
        }

        #endregion
    }
}

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