Example #1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="fieldName">Header field name. For example: "Sender".</param>
        /// <param name="mailbox">Mailbox value.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>filedName</b> or <b>mailbox</b> is null reference.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
        public Mail_h_Mailbox(string fieldName,Mail_t_Mailbox mailbox)
        {
            if(fieldName == null){
                throw new ArgumentNullException("fieldName");
            }
            if(fieldName == string.Empty){
                throw new ArgumentException("Argument 'fieldName' value must be specified.");
            }
            if(mailbox == null){
                throw new ArgumentNullException("mailbox");
            }

            m_Name     = fieldName;
            m_pAddress = mailbox;
        }
Example #2
0
        /// <summary>
        /// Constructs ENVELOPE addresses structure.
        /// </summary>
        /// <param name="mailboxes">Mailboxes.</param>
        /// <param name="wordEncoder">Unicode words encoder.</param>
        /// <returns></returns>
        private static string ConstructAddresses(Mail_t_Mailbox[] mailboxes,MIME_Encoding_EncodedWord wordEncoder)
        {
            StringBuilder retVal = new StringBuilder();
            retVal.Append("(");

            foreach(Mail_t_Mailbox address in mailboxes){
                retVal.Append(ConstructAddress(address,wordEncoder));
            }

            retVal.Append(")");

            return retVal.ToString();
        }
Example #3
0
        /// <summary>
        /// Constructs ENVELOPE address structure.
        /// </summary>
        /// <param name="address">Mailbox address.</param>
        /// <param name="wordEncoder">Unicode words encoder.</param>
        /// <returns></returns>
        private static string ConstructAddress(Mail_t_Mailbox address,MIME_Encoding_EncodedWord wordEncoder)
        {
            /* An address structure is a parenthesized list that describes an
               electronic mail address.  The fields of an address structure
               are in the following order: personal name, [SMTP]
               at-domain-list (source route), mailbox name, and host name.
            */

            // NOTE: all header fields and parameters must in ENCODED form !!!

            StringBuilder retVal = new StringBuilder();
            retVal.Append("(");

            // personal name
            if(address.DisplayName != null){
                retVal.Append(TextUtils.QuoteString(wordEncoder.Encode(RemoveCrlf(address.DisplayName))));
            }
            else{
                retVal.Append("NIL");
            }

            // source route, always NIL (not used nowdays)
            retVal.Append(" NIL");

            // mailbox name
            retVal.Append(" " + TextUtils.QuoteString(wordEncoder.Encode(RemoveCrlf(address.LocalPart))));

            // host name
            if(address.Domain != null){
                retVal.Append(" " + TextUtils.QuoteString(wordEncoder.Encode(RemoveCrlf(address.Domain))));
            }
            else{
                retVal.Append(" NIL");
            }

            retVal.Append(")");

            return retVal.ToString();
        }
Example #4
0
 private string getMailBoxLabel(Mail_t_Mailbox mailBox)
 {
     if (!String.IsNullOrEmpty(mailBox.DisplayName))
         return mailBox.DisplayName;
     else
         return mailBox.LocalPart;
 }
Example #5
0
        /// <summary>
        /// Removes specified item from the collection.
        /// </summary>
        /// <param name="value">Address to remove.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>value</b> is null reference value.</exception>
        public void Remove(Mail_t_Mailbox value)
        {
            if(value == null){
                throw new ArgumentNullException("value");
            }

            m_pList.Remove(value);
        }
Example #6
0
        /// <summary>
        /// Inserts a address into the collection at the specified location.
        /// </summary>
        /// <param name="index">The location in the collection where you want to add the item.</param>
        /// <param name="value">Address to insert.</param>
        /// <exception cref="ArgumentOutOfRangeException">Is raised when <b>index</b> is out of range.</exception>
        /// <exception cref="ArgumentNullException">Is raised when <b>value</b> is null reference.</exception>
        public void Insert(int index,Mail_t_Mailbox value)
        {
            if(index < 0 || index > m_pList.Count){
                throw new ArgumentOutOfRangeException("index");
            }
            if(value == null){
                throw new ArgumentNullException("value");
            }

            m_pList.Insert(index,value);
            m_IsModified = true;
        }
Example #7
0
        /// <summary>
        /// Adds specified address to the end of the collection.
        /// </summary>
        /// <param name="value">Address to add.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>value</b> is null reference value.</exception>
        public void Add(Mail_t_Mailbox value)
        {
            if(value == null){
                throw new ArgumentNullException("value");
            }

            m_pList.Add(value);
            m_IsModified = true;
        }