using System; using System.Collections.Generic; using System.Linq; using System.Web; using MongoDB.Driver; using MongoDB.Bson; using AIAHTML5.API.Properties; using AIAHTML5.API.Constants; using log4net; using System.Net.Mail; using AIAHTML5.API.Utility; using System.Text; using System.IO; using System.Net.Mime; using System.Configuration; namespace AIAHTML5.API.Models { public class ResetUser { public static bool SendEmail(dynamic UserDetails, bool isPassword) { ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); logger.Debug("inside SendEmail in for isPassword =" + isPassword); try { List lstLinkedResource = new List(); EmailUtility emailUtility = new EmailUtility(); List lstToAddress = new List(); List lstBccAddress = new List(); string emailText = string.Empty; string userId = string.Empty; string userMail = string.Empty; string userName = string.Empty; string fName = string.Empty; string lName = string.Empty; string site_url = Convert.ToString(ConfigurationManager.AppSettings["Site_URL"]); foreach (KeyValuePair kvp in UserDetails) { if (kvp.Key == "loginId") userId = kvp.Value.ToString(); if (kvp.Key == "emailId") userMail = kvp.Value.ToString(); if (kvp.Key == "firstName") fName = kvp.Value.ToString(); if (kvp.Key == "lastName") lName = kvp.Value.ToString(); } string fullName = fName + " " + lName; string logoPath = HttpContext.Current.Server.MapPath("~/content/images/logo.png"); string templatePath = string.Empty; string resetPasswordLink = string.Empty; if (isPassword) { templatePath = "~/Templates/forgot-Password.html"; resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail); } else templatePath = "~/Templates/forgot-UserId.html"; logger.Debug("inside SendEmail for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordLink); string mailBody = ResetUser.GetMailBodyTextFromTemplate(templatePath, userId, userMail, fullName, resetPasswordLink); lstToAddress.Add(userMail); emailText = mailBody; logger.Debug("emailText= " + emailText); // for embedding images in email if (emailText.Contains("