Example #1
0
 public void SetFunctionalMailAddress (MailAuthorType authorType, string name, string email)
 {
     if (string.IsNullOrEmpty(email.Trim()))
     {
         functionalMailDict.Remove(authorType);
     }
     else
     {
         functionalMailDict[authorType] = new FunctionalMail.AddressItem(email, name);
     }
     SaveFunctionalMailDict();
 }
Example #2
0
        private void LoadFunctionalMailAddress ()
        {
            if (functionalMailDict == null)
            {
                functionalMailDict = new Dictionary<MailAuthorType, FunctionalMail.AddressItem>();
                string funcMails = OptionalData.GetOptionalDataString(ObjectOptionalDataType.OrgFunctionalMail);
                string[] rows = funcMails.Replace("\r", "\n").Replace("\n\n", "\n").Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

                Regex reSplitAddress = new Regex(@"^(?<Type>.+?):(?<Name>.+)[,;:]\s*(?<Address>\S+?@\S+?)$", RegexOptions.IgnoreCase);
                foreach (string row in rows)
                {
                    Match match = reSplitAddress.Match(row);
                    try
                    {
                        MailAuthorType maType = (MailAuthorType)Enum.Parse(typeof(MailAuthorType), match.Groups["Type"].Value);
                        string name = match.Groups["Name"].Value;
                        string address = match.Groups["Address"].Value;
                        functionalMailDict[maType] = new FunctionalMail.AddressItem(address, name);
                    }
                    catch { }
                }
            }
        }