Click here to Skip to main content
15,897,273 members
Articles / Programming Languages / C#

Understanding the Insides of the POP3 Mail Protocol: Part 2

Rate me:
Please Sign up or sign in to vote.
4.96/5 (32 votes)
9 Dec 2012MIT5 min read 119.1K   3.2K   95  
This article describes the mail sending process for beginners of the mail protocol.
The purpose of this article is to explore the insides of the POP3 protocol and show you how to implement it with C#.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HigLabo.Net
{
    /// <summary>
    /// 
    /// </summary>
    public class AccessTokenInfo
    {
        private Dictionary<String, String> _Values = null;
        private String _Token = "";
        private String _TokenSecret = "";
        /// <summary>
        /// 
        /// </summary>
        public String Token
        {
            get { return _Token; }
            set { _Token = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public String TokenSecret
        {
            get { return _TokenSecret; }
            set { _TokenSecret = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Dictionary<String, String> Values
        {
            get { return _Values; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="token"></param>
        /// <param name="tokenSecret"></param>
        public AccessTokenInfo(String token, String tokenSecret)
        {
            this.Token = token;
            this.TokenSecret = tokenSecret;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="tokenKey"></param>
        /// <param name="tokenSecretKey"></param>
        /// <returns></returns>
        public static AccessTokenInfo Create(String value, String tokenKey, String tokenSecretKey)
        {
            AccessTokenInfo t = new AccessTokenInfo("", "");
            String[] ss = value.Split('&');
            String[] sss = null;
            Dictionary<String, String> d = new Dictionary<string, string>();
            for (int i = 0; i < ss.Length; i++)
            {
                if (ss[i].Contains("=") == false) { continue; }
                sss = ss[i].Split('=');
                if (sss.Length == 2)
                {
                    d[sss[0].ToLower()] = sss[1];
                }
            }
            t._Values = d;
            if (d.ContainsKey(tokenKey) == true)
            {
                t.Token = d[tokenKey];
            }
            if (d.ContainsKey(tokenSecretKey) == true)
            {
                t.TokenSecret = d[tokenSecretKey];
            }
            return t;
        }
   }
}

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 MIT License


Written By
CEO TinyBetter, Inc
Japan Japan
I'm a CEO of TinyBetter, Inc in Japan.

Comments and Discussions