public bool SendEmail(EmailObj email) { if (email != null) { return(true); } return(false); }
public UserResponse PasswordNotification(UserObj param) { bool email = DoesEmailExists(param.Email); if (email) { EmailObj emailModel = new EmailObj(); string AuthUsername = WebConfigurationManager.AppSettings["AuthUsername"]; string AuthPWD = WebConfigurationManager.AppSettings["AuthPWD"]; string PasswordUrl = WebConfigurationManager.AppSettings["PasswordUrl"]; var body = "Kindly click on this link to reset your password. </br>" + PasswordUrl + "?Email=" + param.Email; var message = new MailMessage(); message.To.Add(new MailAddress(param.Email)); // replace with valid value message.From = new MailAddress(WebConfigurationManager.AppSettings["SupportAddress"]); // replace with valid value message.Subject = "Password Update"; message.Body = string.Format(body, emailModel.FromEmail, emailModel.Message); message.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient()) { try { smtp.Host = WebConfigurationManager.AppSettings["EmailHost"]; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(AuthUsername, AuthPWD); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = Convert.ToInt32(WebConfigurationManager.AppSettings["EmailPort"]); smtp.Send(message); return(new UserResponse { RespCode = "00", RespMessage = "kindly check your email" }); } catch (Exception ex) { Log.InfoFormat("Email", ex.Message); return(new UserResponse { RespCode = "01", RespMessage = ex.Message }); } } } else { return(new UserResponse { RespCode = "01", RespMessage = "Invalid email address" }); } }
private void sendEmail(string emailMessage) { string userEmail = txtEmail.Text.Trim(); string userName = txtFName.Text.Trim() + " " + txtLName.Text.Trim(); string[] arrTCCF_Sender, arrTCCF_Recipient; string subject; try { subject = ConfigurationManager.AppSettings["Email_Subject"]; } catch (Exception) { subject = "Online Registration"; } try { EmailObj email = new EmailObj(subject, "", true); arrTCCF_Sender = ConfigurationManager.AppSettings["TCCF_SendingEmail"].Split(';'); arrTCCF_Recipient = ConfigurationManager.AppSettings["TCCF_ContactEmail"].Split(';'); // Email to a contact from TCCF. email.message = emailMessage.Replace("%header%", ""); email.setRecipient(arrTCCF_Recipient[0], arrTCCF_Recipient[1]); email.setSender(arrTCCF_Sender[0], arrTCCF_Sender[1]); if (!string.IsNullOrEmpty(userEmail)) { email.setReplyTo(userEmail, userName); } email.send(null, null); } catch (Exception) { pnlError.Visible = true; return; } // Attempt to send the user a copy of their registration if (!string.IsNullOrEmpty(userEmail)) { string thanksMessage; // Get the thank you message from our web config file. try { thanksMessage = ConfigurationManager.AppSettings["Thanks_Message"]; } catch (Exception) { thanksMessage = ""; } try { thanksMessage += (!string.IsNullOrEmpty(thanksMessage) ? "<br /><br />" : "") + "<strong>The following is a copy of your online registration</strong><br />"; EmailObj email = new EmailObj(subject, "", true); email.message = emailMessage.Replace("%header%", thanksMessage); // Could we do an auto response thanking them for their time and letting them know that // enrollment is not confirmed until we contact them via phone or email? Thanks. email.setRecipient(userEmail, userName); email.setSender(arrTCCF_Sender[0], arrTCCF_Sender[1]); email.send(null, null); } catch (Exception) {} } // If we reach this point then redirect the user to the thank you page. Response.Redirect("~/thanks.aspx", true); }