Example #1
0
        /// <summary>
        /// Quickly create a search query specifying the display name and/or email address for the BCC: field
        /// </summary>
        /// <param name="name">display name of the person to search for</param>
        /// <param name="addr">e-mail address of the person to search for</param>
        /// <returns>IMAPSearchQuery object suitable for passing into the search method</returns>
        public static IMAPSearchQuery QuickSearchBCC(string name, string addr)
        {
            IMAPSearchQuery query = new IMAPSearchQuery();
            IMAPMailAddress a     = new IMAPMailAddress();

            a.Address     = addr;
            a.DisplayName = name;
            query.BCC.Add(a);

            return(query);
        }
Example #2
0
        /// <summary>
        /// Helper method to quickly check whether a specific address exists within the specified list
        /// </summary>
        /// <param name="list">The source list to check</param>
        /// <param name="addr">The address to look for</param>
        /// <returns>True if the address was found, False if it wasnt</returns>
        private bool AddressListContains(List <IMAPMailAddress> list, IMAPMailAddress addr)
        {
            foreach (IMAPMailAddress a in list)
            {
                if (a.Address.Equals(addr.Address) || a.DisplayName.Equals(addr.DisplayName))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
        /// <summary>
        /// Quickly create a search query specifying the display name and/or email address for the BCC: field
        /// </summary>
        /// <param name="name">display name of the person to search for</param>
        /// <param name="addr">e-mail address of the person to search for</param>
        /// <returns>IMAPSearchQuery object suitable for passing into the search method</returns>
        public static IMAPSearchQuery QuickSearchBCC(string name, string addr)
        {
            IMAPSearchQuery query = new IMAPSearchQuery();
            IMAPMailAddress a = new IMAPMailAddress();
            a.Address = addr;
            a.DisplayName = name;
            query.BCC.Add(a);

            return query;
        }
Example #4
0
        /// <summary>
        /// Helper method to quickly check whether a specific address exists within the specified list
        /// </summary>
        /// <param name="list">The source list to check</param>
        /// <param name="addr">The address to look for</param>
        /// <returns>True if the address was found, False if it wasnt</returns>
        private bool AddressListContains(List<IMAPMailAddress> list, IMAPMailAddress addr)
        {
            foreach (IMAPMailAddress a in list)
            {
                if (a.Address.Equals(addr.Address) || a.DisplayName.Equals(addr.DisplayName))
                    return true;
            }

            return false;
        }
Example #5
0
        private IMAPMailAddress GetAddressFromString(string s)
        {
            IMAPMailAddress addr = new IMAPMailAddress();
            bool hasDisplayName = false;
            int idxAddr = 0;
            int idxAddrEnd = 0;

            s = s.Trim();
            idxAddr = s.IndexOf("<");
            idxAddrEnd = s.IndexOf(">");
            if (idxAddrEnd == -1)
                idxAddrEnd = s.Length - 1;
            // first we need to check if there is a display name or not
            if (idxAddr > 0)
            {
                // if the '<' that denotes the address is not in the first character then we know there is a display name
                hasDisplayName = true;
            }

            if (hasDisplayName)
            {
                string tempName = s;
                tempName = tempName.Remove(idxAddr);
                string tempAddr = s.Substring(idxAddr+1, idxAddrEnd - idxAddr);
                // tempName should now only contain the display name data
                // tempAddr should now only contain the address

                addr.DisplayName = tempName.Replace("\"", "").Trim();
                addr.Address = tempAddr.Replace("<", "").Replace(">", "").Trim();
            }
            else
            {
                string tempAddr = s;

                if (idxAddr > 0 && idxAddrEnd > 0)
                    tempAddr = s.Substring(idxAddr + 1, idxAddrEnd - idxAddr);

                addr.DisplayName = tempAddr.Replace("<","").Replace(">","").Trim();
                addr.Address = tempAddr.Replace("<","").Replace(">","").Trim();
            }

            addr.DisplayName = addr.DisplayName.Replace("\"", "");
            addr.Address = addr.Address.Replace("\"", "");

            return addr;
        }