Ejemplo n.º 1
0
 private ImapAddressList CreateCollection(string AddressList)
 {
     AddressList = Regex.Replace(AddressList, "\\\\\"", "'");
     AddressList = Regex.Replace(AddressList, @"\.\.", ".");
     //if (AddressList.Contains("Carleton"))
     //    throw new Exception();
     ImapAddressList Addresses = new ImapAddressList();
     MatchCollection matches = Regex.Matches(AddressList, @"\(((?>\((?<LEVEL>)|\)(?<-LEVEL>)|(?! \( | \) ).)+(?(LEVEL)(?!)))\)$");
     foreach (Match match in matches)
     {
         StringBuilder displayName = new StringBuilder("");
         StringBuilder email = new StringBuilder("");
         string value = match.Groups[1].ToString().Trim();
         // Display Name
         if (!(value.StartsWith("NIL")))
         {
             Match sub;
             if ((sub = Regex.Match(value, @"^{(\d+)}(.*)")).Success) {
                 value = "\"" + sub.Groups[2].Value.Insert(Convert.ToInt32(sub.Groups[1].Value), "\"");
             }
             sub = Regex.Match(value, @"""([^""]+)""");
             displayName.Append(sub.Groups[1].ToString());
             value = value.Substring(sub.Length).Trim();
         }
         else
             value = value.Substring(3).Trim();
         // Display Name Extended
         if (!(value.StartsWith("NIL")))
         {
             Match sub;
             if ((sub = Regex.Match(value, @"^{(\d+)}(.*)")).Success)
             {
                 value = "\"" + sub.Groups[2].Value.Insert(Convert.ToInt32(sub.Groups[1].Value), "\"");
             }
             sub = Regex.Match(value, @"""([^""]+)""");
             displayName.Append(" " + sub.Groups[1].ToString());
             value = value.Substring(sub.Length).Trim();
         }
         else
             value = value.Substring(3).Trim();
         // Email Prefix
         if (!(value.StartsWith("NIL")))
         {
             Match sub;
             if ((sub = Regex.Match(value, @"^{(\d+)}(.*)")).Success)
             {
                 value = "\"" + sub.Groups[2].Value.Insert(Convert.ToInt32(sub.Groups[1].Value), "\"");
             }
             sub = Regex.Match(value, @"""([^""]+)""");
             email.Append(sub.Groups[1].ToString());
             value = value.Substring(sub.Length).Trim();
         }
         else
             value = value.Substring(3).Trim();
         // Email Suffix
         if (!(value.StartsWith("NIL")))
         {
             Match sub;
             if ((sub = Regex.Match(value, @"^{(\d+)}(.*)")).Success)
             {
                 value = "\"" + sub.Groups[2].Value.Insert(Convert.ToInt32(sub.Groups[1].Value), "\"");
             }
             sub = Regex.Match(value, @"""([^""]+)""");
             email.Append("@" + sub.Groups[1].ToString());
             value = value.Substring(sub.Length).Trim();
         }
         else
             value = value.Substring(3).Trim();
         if (email.ToString().IndexOf('@') < 0)
             email = new StringBuilder("undisclosed-recipients@localhost");
         ImapAddress address = new ImapAddress(email.ToString(), ImapDecode.Decode(displayName.ToString()));
         Addresses.Add(address);
         //return Addresses; // not sure how this got here.
     }
     return Addresses;
 }
Ejemplo n.º 2
0
 public void FormatExceptionAddressSimple()
 {
     ImapAddress address = new ImapAddress(_invalidaddress);
 }
Ejemplo n.º 3
0
 public void FormatExceptionAddressComplex()
 {
     ImapAddress address = new ImapAddress(_invalidaddress, _name, _encoding);
 }
Ejemplo n.º 4
0
 public void FormatExceptionAddressNormal()
 {
     ImapAddress address = new ImapAddress(_invalidaddress, _name);
 }
Ejemplo n.º 5
0
 protected void Init()
 {
     address1 = new ImapAddress(_emailaddress);
     address2 = new ImapAddress(_emailaddress, _name);
     address3 = new ImapAddress(_emailaddress, _name, _encoding);
 }