Exemplo n.º 1
0
        /// <summary>
        /// Adds a key-value pair to the e-mail header.
        /// For well-known headers, e.g. FROM, TO, ... simple validations checks are performed.
        /// </summary>
        /// <remarks>For an e-mail the order of the header lines is often important! Keys are NOT unique, e.g. RECEIVED!</remarks>
        /// <param name="Key">The property key.</param>
        /// <param name="Value">The property value.</param>
        public AbstractEMail AddEMailHeader(String Key, String Value)
        {
            switch (Key.ToLower())
            {
            case "from":
                if (SimpleEMailAddress.IsValid(Value))
                {
                    this._MailHeaders.Add(new KeyValuePair <String, String>(Key, Value));
                }
                break;

            case "to":
                if (SimpleEMailAddress.IsValid(Value))
                {
                    this._MailHeaders.Add(new KeyValuePair <String, String>(Key, Value));
                }
                break;

            case "cc":
                if (SimpleEMailAddress.IsValid(Value))
                {
                    this._MailHeaders.Add(new KeyValuePair <String, String>(Key, Value));
                }
                break;

            case "subject":
                this._MailHeaders.Add(new KeyValuePair <String, String>(Key, Value));
                break;

            default: _MailHeaders.Add(new KeyValuePair <String, String>(Key, Value));
                break;
            }

            return(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new e-mail address.
        /// </summary>
        /// <param name="SimpleEMailAddressString">A string representation of a simple e-mail address.</param>
        /// <param name="SecretKeyRing">The secret key ring for an e-mail address.</param>
        /// <param name="PublicKeyRing">The public key ring for an e-mail address.</param>
        public EMailAddress(String SimpleEMailAddressString,
                            PgpSecretKeyRing SecretKeyRing = null,
                            PgpPublicKeyRing PublicKeyRing = null)

            : this("", SimpleEMailAddress.Parse(SimpleEMailAddressString), SecretKeyRing, PublicKeyRing)

        {
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a new e-mail address.
        /// </summary>
        /// <param name="SimpleEMailAddress">A simple e-mail address.</param>
        /// <param name="SecretKeyRing">The secret key ring for an e-mail address.</param>
        /// <param name="PublicKeyRing">The public key ring for an e-mail address.</param>
        public EMailAddress(SimpleEMailAddress SimpleEMailAddress,
                            PgpSecretKeyRing SecretKeyRing = null,
                            PgpPublicKeyRing PublicKeyRing = null)

            : this("", SimpleEMailAddress, SecretKeyRing, PublicKeyRing)

        {
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a new e-mail address.
        /// </summary>
        /// <param name="OwnerName">The name of the owner of the e-mail address.</param>
        /// <param name="SimpleEMailAddress">A simple e-mail address.</param>
        /// <param name="SecretKeyRing">The secret key ring for an e-mail address.</param>
        /// <param name="PublicKeyRing">The public key ring for an e-mail address.</param>
        public EMailAddress(String OwnerName,
                            SimpleEMailAddress SimpleEMailAddress,
                            PgpSecretKeyRing SecretKeyRing = null,
                            PgpPublicKeyRing PublicKeyRing = null)

        {
            this._OwnerName     = OwnerName.Trim();
            this._Address       = SimpleEMailAddress;
            this._PublicKeyRing = PublicKeyRing;
            this._SecretKeyRing = SecretKeyRing;
        }
Exemplo n.º 5
0
        public static EMailAddress Parse(String EMailString)
        {
            if (EMailString.IsNullOrEmpty())
            {
                return(null);
            }

            var b = EMailString.IndexOf('<');
            var c = EMailString.IndexOf('>');

            if (b >= 0 && c > b)
            {
                return(new EMailAddress(EMailString.Remove(b, c - b + 1).Trim(), SimpleEMailAddress.Parse(EMailString.Substring(b + 1, c - b - 1).Trim())));
            }

            return(new EMailAddress(SimpleEMailAddress.Parse(EMailString)));
        }