/// <summary> /// Set To Address to the Mail /// </summary> /// <param name="mailMessage"></param> /// <param name="mailMsg"></param> private void SetToaddress(System.Web.Mail.MailMessage mailMessage, MailMessage mailMsg) { try { //checking toAddress string is null or empty if it not null then add to mail if (!String.IsNullOrEmpty(ToAddress)) { //split the toAddress string and add to an array string[] toArray = ToAddress.Split(";".ToCharArray()); ValidateRecipientEmail(toArray);//validating the email address //if mail is net.mail if (IsSmtpClientMail) { foreach (string to in toArray.Where(to => !to.Equals(""))) { mailMsg.To.Add(to); //add toAddress array to mailmessage.To } } else { //if mail is web.mail set toAddress string to MailMessage.To ToAddress = ToAddress.TrimEnd(';'); mailMessage.To = ToAddress; //multiple to address } } else { //Toaddress is null the set ToFlag=1 ToFlag = 1; } } catch (Exception ex) { throw ex; } }