Click here to Skip to main content
15,892,059 members
Articles / Programming Languages / C#

IMAP and POP3 Clients in C#

Rate me:
Please Sign up or sign in to vote.
4.67/5 (21 votes)
28 Sep 2012CPOL1 min read 258.7K   16.6K   48  
IMAP & POP3 Clients C#. A library for intuitive ease of use of these two protocols.
using System;
using System.Collections.Generic;
using System.Text;

namespace LumiSoft.Net.POP3.Server
{
    /// <summary>
    /// This class represents POP3 server message.
    /// </summary>
    public class POP3_ServerMessage
    {
        private int    m_SequenceNumber      = -1;
        private string m_UID                 = "";
        private int    m_Size                = 0;
        private bool   m_IsMarkedForDeletion = false;
        private object m_pTag                = null;

        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="uid">Message UID value.</param>
        /// <param name="size">Message size in bytes.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>uid</b> is null reference.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
        public POP3_ServerMessage(string uid,int size) : this(uid,size,null)
        {
        }

        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="uid">Message UID value.</param>
        /// <param name="size">Message size in bytes.</param>
        /// <param name="tag">User data.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>uid</b> is null reference.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
        public POP3_ServerMessage(string uid,int size,object tag)
        {
            if(uid == null){
                throw new ArgumentNullException("uid");
            }
            if(uid == string.Empty){
                throw new ArgumentException("Argument 'uid' value must be specified.");
            }
            if(size < 0){
                throw new ArgumentException("Argument 'size' value must be >= 0.");
            }

            m_UID  = uid;
            m_Size = size;
            m_pTag = tag;
        }


        #region method SetIsMarkedForDeletion

        /// <summary>
        /// Sets IsMarkedForDeletion proerty value.
        /// </summary>
        /// <param name="value">Value.</param>
        internal void SetIsMarkedForDeletion(bool value)
        {
            m_IsMarkedForDeletion = value;
        }

        #endregion


        #region Properties implemnetation
                
        /// <summary>
        /// Gets message UID. NOTE: Before accessing this property, check that server supports UIDL command.
        /// </summary>
        public string UID
        {
            get{ return m_UID; }
        }

        /// <summary>
        /// Gets message size in bytes.
        /// </summary>
        public int Size
        {
            get{ return m_Size; }
        }

        /// <summary>
        /// Gets if message is marked for deletion.
        /// </summary>
        public bool IsMarkedForDeletion
        {
            get{ return m_IsMarkedForDeletion; }
        }

        /// <summary>
        /// Gets or sets user data.
        /// </summary>
        public object Tag
        {
            get{ return m_pTag; }

            set{ m_pTag = value; }
        }


        /// <summary>
        /// Gets message 1 based sequence number.
        /// </summary>
        /// <exception cref="ObjectDisposedException">Is raised when this object is disposed and this property is accessed.</exception>
        internal int SequenceNumber
        {
            get{ return m_SequenceNumber; }

            set{ m_SequenceNumber = value; }
        }

        #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) D.Net Solution
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions