Introduction This solution describes an approach how to send email messages with or without attachments. Background The EmailProgram class is used to send email messages with or without attachments. The code Code: public class EmailProgram { /// <summary> /// call this Method to send an Email with attachments /// </summary> /// <param name="emailFrom">From EmailID</param> /// <param name="emailTo">To Email ID</param> /// <param name="emailCC">CC Email ID</param> /// <param name="emailBCC">BCC Email ID</param> /// <param name="subject">Subject</param> /// <param name="body">Body</param> /// <param name="IsBodyHtml">EmailBodyFormat(Default It is false, If It is true EmailBody should in HTML Format)</param> /// <param name="attachmentPath">Attachment File Path</param> /// <returns>If sends successfully returns True otherwise False</returns> public String SendMail(String emailFrom, String emailTo, String emailCC, String emailBCC, String subject, String body, ArrayList attachments, bool IsBodyHtml) { try { bool ValidateFromEmailAddress = ValidateEmailAddress(emailFrom); if (ValidateFromEmailAddress == false) return "Invalid From Email Address: " + emailFrom; bool ValidateToEmailAddress = ValidateEmailAddress(emailTo); if (ValidateToEmailAddress == false) return "Invalid To Email Address: " + emailTo; MailAddress mailFrom = new MailAddress(emailFrom); MailAddress mailTo = new MailAddress(emailTo); MailMessage mailMessage = new MailMessage(mailFrom, mailTo); mailMessage.Subject = subject; mailMessage.Body = body; mailMessage.IsBodyHtml = IsBodyHtml; if (!String.IsNullOrEmpty(emailCC)) { bool ValidateCCEmailAddress = ValidateEmailAddress(emailCC); if (ValidateCCEmailAddress == false) return "Invalid CC Email Address: " + emailCC; mailMessage.CC.Add(emailCC); } if (!String.IsNullOrEmpty(emailBCC)) { bool ValidateBCCEmailAddress = ValidateEmailAddress(emailBCC); if (ValidateBCCEmailAddress == false) return "Invalid BCC Email Address: " + emailBCC; mailMessage.Bcc.Add(emailBCC); } foreach (string attach in attachments) { Attachment attached = new Attachment(attach, MediaTypeNames.Application.Octet); mailMessage.Attachments.Add(attached); } String strSMTPServer = ConfigurationSettings.AppSettings.Get("SMTPServer"); SmtpClient smtpClient = new SmtpClient(strSMTPServer); //smtpClient.Credentials = new NetworkCredential("UserName", "Password");//if credentials needed smtpClient.UseDefaultCredentials = true; if (mailMessage != null) { smtpClient.Send(mailMessage); } return "Message sent to " + emailTo + " at " + DateTime.Now.ToString() + "."; } catch (Exception ex) { return ex.Message.ToString(); } } /// <summary> /// check email address is valid or not /// </summary> /// <param name="emailAddress">email address to validate</param> /// <returns>True if email address is valid</returns> public bool ValidateEmailAddress(string emailAddress) { try { string TextToValidate = emailAddress; Regex expression = new Regex(@"\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}"); if (expression.IsMatch(TextToValidate)) { return true; } else { return false; } } catch (Exception) { throw; } } }