Click here to Skip to main content
15,897,891 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 259.3K   16.6K   48  
IMAP & POP3 Clients C#. A library for intuitive ease of use of these two protocols.
using System;

namespace LumiSoft.Net.Mime
{
	/// <summary>
	/// RFC 2822 3.4. (Address Specification) Group address.
	/// <p/>
	/// Syntax: display-name':'[mailbox *(',' mailbox)]';'
	/// </summary>
    [Obsolete("See LumiSoft.Net.MIME or LumiSoft.Net.Mail namepaces for replacement.")]
	public class GroupAddress : Address
	{
		private string                   m_DisplayName   = "";
		private MailboxAddressCollection m_pGroupMembers = null;

		/// <summary>
		/// Default constructor.
		/// </summary>
		public GroupAddress() : base(true)
		{
			m_pGroupMembers = new MailboxAddressCollection();
			m_pGroupMembers.Owner = this;
		}


		#region static method Parse
		
		/// <summary>
		/// Parses Rfc 2822 3.4 group address from group address string. Syntax: display-name':'[mailbox *(',' mailbox)]';'
		/// </summary>
		/// <param name="group">Group address string.</param>
		/// <returns></returns>
		public static GroupAddress Parse(string group)
		{
			GroupAddress g = new GroupAddress();

			// Syntax: display-name':'[mailbox *(',' mailbox)]';'
			string[] parts = TextUtils.SplitQuotedString(group,':');
			if(parts.Length > -1){
				g.DisplayName = TextUtils.UnQuoteString(parts[0]);				
			}
			if(parts.Length > 1){
				g.GroupMembers.Parse(parts[1]);
			}

			return g;
		}

		#endregion


		#region internal method OnChanged

		/// <summary>
		/// This called when group address has changed.
		/// </summary>
		internal void OnChanged()
		{
			if(this.Owner != null){
				if(this.Owner is AddressList){
					((AddressList)this.Owner).OnCollectionChanged();
				}				
			}
		}

		#endregion


		#region Properties implementation

		/// <summary>
		/// Gets Group as RFC 2822(3.4. Address Specification) string. Syntax: display-name':'[mailbox *(',' mailbox)]';'
		/// </summary>
		public string GroupString
		{
			get{ return TextUtils.QuoteString(this.DisplayName) + ":" + this.GroupMembers.ToMailboxListString() + ";"; }
		}

		/// <summary>
		/// Gets or sets display name.
		/// </summary>
		public string DisplayName
		{
			get{ return m_DisplayName; }

			set{ 
				m_DisplayName = value; 

				OnChanged();
			}
		}

		/// <summary>
		/// Gets group members collection.
		/// </summary>
		public MailboxAddressCollection GroupMembers
		{
			get{ return m_pGroupMembers; }
		}

		#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