C#多個(gè)郵件地址是否合法、重復(fù)、以及字符串首尾去逗號(hào)代碼及其他處理
當(dāng)前位置:點(diǎn)晴教程→知識(shí)管理交流
→『 技術(shù)文檔交流 』
string addresses = ""; AddressList = AddressList.Replace(",", ",").Replace(";", ",").Replace(";", ",").Trim(); string[] strArray = AddressList.Split(new char[] { ',' }); int length = strArray.Length; for (int i = 0; i < length; i++) { //判斷地址是否合法、是否重復(fù) if (((strArray[i].Contains("@") && strArray[i].Contains(".")) && !addresses.ToLower().Contains((strArray[i] + ",").ToLower())) && (strArray[i].Trim ().ToLower().IndexOf(str.Trim().ToLower()) > 0)) { addresses = addresses + strArray[i] + ","; } } if (addresses.EndsWith(",")) { addresses = addresses.Substring(0, addresses.Length - 1); } if (addresses.StartsWith(",")) { addresses = addresses.Substring(1, addresses.Length - 1); } mailMessage.To.Add(addresses);
該文章在 2017/11/7 22:35:04 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |