public string SendOTPEmail(string EmailID, string OTP, string UserName) { string status = string.Empty; string EmailSending_Status = string.Empty; string UserId = string.Empty; string PassWord = string.Empty; string EmailFrom = string.Empty; string SMTPHost = string.Empty; string EmailDomain = string.Empty; System.Net.Mail.MailMessage Msg = new System.Net.Mail.MailMessage(); try { { UserId = "xyz"; PassWord = "abc"; EmailFrom = "abc@aaa.com"; EmailDomain ="aaa.com"; NetworkCredential basicAuthenticationInfo = new NetworkCredential(UserId, PassWord, EmailDomain); SMTPHost = "abc.com"; string EmailFromName = "aaa.aa@ssss.com"; Msg.Subject = "Please complete your customer registration"; Msg.From = new System.Net.Mail.MailAddress(EmailFrom, EmailFromName); Msg.To.Add(new System.Net.Mail.MailAddress(EmailID)); Msg.IsBodyHtml = true; Msg.Body = " Dear Sir/Madam," + "" + "<br>" + "" + "<br>" + "TATA AIG General Insurance welcomes you to its Portal." + "" + "<br>" + "Please enter the One Time Password:" + OTP + " to complete your Registration " + "" + "" + "<br>" + "This One Time Password is valid for 24 hours." + "" + "<br>" + "" + "<br>" + "" + "<br>" + "Thanks and Regards" + "<br>" + "Portal Admin" + "<br>" + "" + "<br>" + "" + "<br>" + "" + "<br>" + "Note: This is a system-generated e-mail. Please do not reply back."; SmtpClient smClient = new SmtpClient(); smClient.Host = SMTPHost; smClient.Port = 587; smClient.EnableSsl = false; smClient.UseDefaultCredentials = false; smClient.Credentials = basicAuthenticationInfo; if (ValidSMTP(SMTPHost)) { smClient.Send(Msg); EmailSending_Status = "sent"; status = "OTP sent to your Mailbox successfully."; } else { EmailSending_Status = "Mailserver Down"; status = "Failed"; } } } catch (SmtpException ex) { status = ex.Message; EmailSending_Status = "failed"; } return status; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)