public MailHelper(string receiveremail, string link, string receiverName, string templateType, string templateBody, string subject, string workSpaceName, SMTPSettingsModel sMTPSettingsModel, string message, string notificationEmailMessage, string notificationEmailFromValue, string levelName, string entryFilledByUser, string entryDetails) { templateBody = UpdateTemplateBody(link, receiverName, templateType, templateBody, workSpaceName, message, notificationEmailMessage, levelName, entryFilledByUser, "", "", "", "", receiveremail, "", entryDetails); SendHtmlFormattedEmail(templateBody, receiveremail, subject, sMTPSettingsModel, workSpaceName, templateType, notificationEmailFromValue, "", ""); }
private void SendHtmlFormattedEmail(string templateBody, string receiveremail, string subject, SMTPSettingsModel sMTPSettingsModel, string workSpaceName, string templateType, string notificationEmailFromValue, string attachmentPath, string attachmentName) { using (MailMessage mailMessage = new MailMessage()) { if (templateType == TemplateTypes.ShareRefferalLink.ToString()) { mailMessage.From = new MailAddress(sMTPSettingsModel.Sender, "Blazeforms! Referred a Blazeforms Link"); } else if (templateType == TemplateTypes.SendEmailOnsubmit.ToString()) { mailMessage.From = new MailAddress(sMTPSettingsModel.Sender, notificationEmailFromValue); } else { mailMessage.From = new MailAddress(sMTPSettingsModel.Sender); } if (!string.IsNullOrEmpty(attachmentPath)) { System.Net.Mail.Attachment attachment; attachment = new System.Net.Mail.Attachment(@attachmentPath); attachment.Name = attachmentName; mailMessage.Attachments.Add(attachment); } mailMessage.Subject = subject; mailMessage.Body = templateBody; mailMessage.IsBodyHtml = true; foreach (var address in receiveremail.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries)) { mailMessage.To.Add(address); } SmtpClient smtp = new SmtpClient(); smtp.Host = sMTPSettingsModel.Host; smtp.EnableSsl = sMTPSettingsModel.EnableSSl; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(); NetworkCred.UserName = sMTPSettingsModel.UserName; NetworkCred.Password = sMTPSettingsModel.Password; smtp.UseDefaultCredentials = false; smtp.Credentials = NetworkCred; smtp.Port = sMTPSettingsModel.Port; smtp.Timeout = 30000000; try { //ServiceReference1.Service1Client clientData = new ServiceReference1.Service1Client(); //var response = (clientData.SendEmailAsync(receiveremail, templateBody, subject)).Result; smtp.Send(mailMessage); } catch (Exception ex) { throw ex; } } }
public MailHelper(string receiveremail, string receiverName, string templateType, string templateBody, string subject, string workSpaceName, SMTPSettingsModel sMTPSettingsModel, string userEmail, string planName) { templateBody = UpdateTemplateBody("", receiverName, templateType, templateBody, workSpaceName, "", "", "", "", "", "", "", userEmail, "", planName, ""); SendHtmlFormattedEmail(templateBody, receiveremail, subject, sMTPSettingsModel, "", templateType, "", "", ""); }
public MailHelper(string senderEmail, string senderName, string message, string templateType, string templateBody, string subject, SMTPSettingsModel sMTPSettingsModel, string userEmail) { templateBody = UpdateTemplateBody("", senderName, templateType, templateBody, "", message, "", "", "", "", "", "", userEmail, "", "", ""); SendHtmlFormattedEmail(templateBody, senderEmail, subject, sMTPSettingsModel, "", templateType, "", "", ""); }
public MailHelper(string receiveremail, string link, string receiverName, string templateType, string templateBody, string subject, string workSpaceName, SMTPSettingsModel sMTPSettingsModel, string formName, string oldEmail) { templateBody = UpdateTemplateBody(link, receiverName, templateType, templateBody, workSpaceName, "", "", "", "", formName, "", "", oldEmail, receiveremail, "", ""); SendHtmlFormattedEmail(templateBody, receiveremail + ";" + oldEmail, subject, sMTPSettingsModel, workSpaceName, templateType, "", "", ""); }
public MailHelper(string receiveremail, string link, string receiverName, string templateType, string templateBody, string subject, string workSpaceName, SMTPSettingsModel sMTPSettingsModel, string attachmentPath, string attachmentName, string amount, string chargeId) { templateBody = UpdateTemplateBody(link, receiverName, templateType, templateBody, workSpaceName, "", "", "", "", "", amount, chargeId, "", "", "", ""); SendHtmlFormattedEmail(templateBody, receiveremail, subject, sMTPSettingsModel, workSpaceName, templateType, "", attachmentPath, attachmentName); }