public void SendOfflineChatEmail(int LoginUserID, int UserID, string LoginUserInstallID, string Message, int ChatSource, string BaseUrl, string chatGroupId) { // Get Html Template string messageUrl = string.Empty, toEmail = string.Empty, body = string.Empty; //string BaseUrl = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority + System.Web.HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/"; HTMLTemplatesMaster html = HTMLTemplateBLL.Instance.GetHTMLTemplateMasterById(HTMLTemplates.HR_EditSales_TouchpointLog_Email); // sender details var sender = InstallUserBLL.Instance.getuserdetails(LoginUserID).Tables[0].Rows[0]; string pic = string.IsNullOrEmpty(sender["Picture"].ToString()) ? "default.jpg" : sender["Picture"].ToString().Replace("~/UploadeProfile/", ""); pic = BaseUrl + "Employee/ProfilePictures/" + pic; html.Body = html.Body.Replace("{ImageUrl}", pic); html.Body = html.Body.Replace("{Name}", sender["FristName"].ToString() + " " + sender["LastName"].ToString()); html.Body = html.Body.Replace("{Designation}", sender["Designation"].ToString()); html.Body = html.Body.Replace("{UserInstallID}", sender["UserInstallID"].ToString()); html.Body = html.Body.Replace("{ProfileUrl}", BaseUrl + "Sr_App/ViewSalesUser.aspx?id=" + sender["Id"].ToString()); html.Body = html.Body.Replace("{MessageContent}", Message.Replace("Note :", "").Trim()); // Generate auto login code string loginCode = InstallUserDAL.Instance.GenerateLoginCode(UserID).Object; var receiver = InstallUserBLL.Instance.getuserdetails(UserID).Tables[0].Rows[0]; toEmail = receiver["Email"].ToString(); messageUrl = BaseUrl + "Sr_App/TouchPointLog.aspx?TUID=" + UserID + "&CGID=" + chatGroupId + "&auth=" + loginCode + "&RcvrID=" + LoginUserID + "&Src=" + ChatSource; body = (html.Header + html.Body + html.Footer).Replace("{MessageUrl}", messageUrl); EmailManager.SendEmail("New Message", toEmail, html.Subject, body, null); }
public long SendCallConnectedAutoEmail(int LoginUserID, int UserID, string LoginUserInstallID, string Message, int ChatSource, string BaseUrl, string chatGroupId, int userChatGroupId, string receiverIds) { var receiver = InstallUserBLL.Instance.getuserdetails(UserID).Tables[0].Rows[0]; // Get Html Template string messageUrl = string.Empty, toEmail = string.Empty, body = string.Empty; //string BaseUrl = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority + System.Web.HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/"; DesignationHTMLTemplate html = HTMLTemplateBLL.Instance.GetDesignationHTMLTemplate(HTMLTemplates.Call_Connected_Auto_Email, ""); // sender details var sender = InstallUserBLL.Instance.getuserdetails(LoginUserID).Tables[0].Rows[0]; string pic = string.IsNullOrEmpty(sender["Picture"].ToString()) ? "default.jpg" : sender["Picture"].ToString().Replace("~/UploadeProfile/", ""); pic = BaseUrl + "Employee/ProfilePictures/" + pic; html.Body = html.Body.Replace("{ImageUrl}", pic); html.Body = html.Body.Replace("{SenderName}", sender["FristName"].ToString() + " " + sender["LastName"].ToString()); html.Body = html.Body.Replace("{SenderDesignation}", sender["Designation"].ToString()); html.Body = html.Body.Replace("{SenderUserInstallID}", sender["UserInstallID"].ToString()); html.Body = html.Body.Replace("{ProfileUrl}", BaseUrl + "Sr_App/ViewSalesUser.aspx?id=" + sender["Id"].ToString()); html.Body = html.Body.Replace("{ReceiverEmail}", receiver["Email"].ToString()); html.Body = html.Body.Replace("{ReceiverPhone}", receiver["Phone"].ToString()); html.Body = html.Body.Replace("{ReceiverName}", receiver["FristName"].ToString() + " " + receiver["LastName"].ToString()); // Generate auto login code string loginCode = InstallUserDAL.Instance.GenerateLoginCode(UserID).Object; toEmail = receiver["Email"].ToString(); messageUrl = BaseUrl + "Sr_App/TouchPointLog.aspx?TUID=" + UserID + "&CGID=" + chatGroupId + "&auth=" + loginCode + "&RcvrID=" + receiverIds + "&Src=" + ChatSource + "&ugid=" + userChatGroupId; body = (html.Header + html.Body + html.Footer).Replace("{MessageUrl}", messageUrl); return(EmailManager.SendEmail(JGConstant.EmailTypes.CallConectedAutoEmail.ToString(), html.Subject, toEmail, html.Subject, body, null)); }
public int AddTouchPointLogRecord(int LoginUserID, int UserID, string LoginUserInstallID, DateTime now, string ChangeLog, string strGUID, int touchPointSource) { var LastUserTouchPoint = InstallUserDAL.Instance.GetUserTouchPointLogs(0, 1, UserID).Data; int UserTouchPointLogID = InstallUserDAL.Instance.AddTouchPointLogRecord(LoginUserID, UserID, LoginUserInstallID, now, ChangeLog, strGUID, touchPointSource); // Send email to User / Recruiter // Get Html Template string messageUrl = string.Empty, toEmail = string.Empty, body = string.Empty; string baseUrl = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority + System.Web.HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/"; HTMLTemplatesMaster html = HTMLTemplateBLL.Instance.GetHTMLTemplateMasterById(HTMLTemplates.HR_EditSales_TouchpointLog_Email); // sender details var sender = getuserdetails(LoginUserID).Tables[0].Rows[0]; string pic = string.IsNullOrEmpty(sender["Picture"].ToString()) ? "default.jpg" : sender["Picture"].ToString().Replace("~/UploadeProfile/", ""); pic = baseUrl + "Employee/ProfilePictures/" + pic; html.Body = html.Body.Replace("{ImageUrl}", pic); html.Body = html.Body.Replace("{Name}", sender["FristName"].ToString() + " " + sender["LastName"].ToString()); html.Body = html.Body.Replace("{Designation}", sender["Designation"].ToString()); html.Body = html.Body.Replace("{UserInstallID}", sender["UserInstallID"].ToString()); html.Body = html.Body.Replace("{ProfileUrl}", baseUrl + "Sr_App/ViewSalesUser.aspx?id=" + sender["Id"].ToString()); html.Body = html.Body.Replace("{MessageContent}", ChangeLog.Replace("Note :", "").Trim()); // // Generate auto login code string loginCode = InstallUserDAL.Instance.GenerateLoginCode(UserID).Object; if (LastUserTouchPoint == null && LoginUserID == UserID) // first entry { // send email to recruiter toEmail = "*****@*****.**"; messageUrl = baseUrl + "Sr_App/edituser.aspx?TUID=" + UserID + "&NID=" + UserTouchPointLogID + "&auth=" + loginCode; } else if (LastUserTouchPoint != null && LastUserTouchPoint.Count() > 0 && LoginUserID == UserID) // send email to receiver { // send email to user var lastSender = getuserdetails(LastUserTouchPoint.First().UpdatedByUserID).Tables[0].Rows[0]; if (Convert.ToInt32(lastSender["Id"]) == UserID) { toEmail = lastSender["Email"].ToString(); messageUrl = baseUrl + "Sr_App/TouchPointLog.aspx?TUID=" + UserID + "&NID=" + UserTouchPointLogID + "&auth=" + loginCode; } else { toEmail = lastSender["Email"].ToString(); messageUrl = baseUrl + "Sr_App/edituser.aspx?TUID=" + UserID + "&NID=" + UserTouchPointLogID + "&auth=" + loginCode; } } else { var receiver = getuserdetails(UserID).Tables[0].Rows[0]; // send email to user toEmail = receiver["Email"].ToString(); messageUrl = baseUrl + "Sr_App/TouchPointLog.aspx?TUID=" + UserID + "&NID=" + UserTouchPointLogID + "&auth=" + loginCode; } body = (html.Header + html.Body + html.Footer).Replace("{MessageUrl}", messageUrl); EmailManager.SendEmail("Touch Point Log", toEmail, html.Subject, body, null); // find all emails List <string> emails = new List <string>(); // emails.Add(toEmail); string[] allWords = ChangeLog.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in allWords) { switch (item.Trim().ToLower().Substring(0, item.IndexOf(' '))) { case "justin": if (toEmail != "*****@*****.**") { emails.Add("*****@*****.**"); //321 } // add touch point note entry break; case "yogesh": if (toEmail != "*****@*****.**") { emails.Add("*****@*****.**"); //901 } break; default: break; } } if (emails.Count > 1) { foreach (var item in emails.Distinct()) { switch (item) { case "*****@*****.**": UserTouchPointLogID = InstallUserDAL.Instance.AddTouchPointLogRecord(LoginUserID, 321, LoginUserInstallID, now, ChangeLog, strGUID, touchPointSource); messageUrl = baseUrl + "Sr_App/TouchPointLog.aspx?TUID=" + UserID + "&NID=" + UserTouchPointLogID + "&auth=" + loginCode; body = (html.Header + html.Body + html.Footer).Replace("{MessageUrl}", messageUrl); EmailManager.SendEmail("Touch Point Log", item, html.Subject, body, null); break; case "*****@*****.**": UserTouchPointLogID = InstallUserDAL.Instance.AddTouchPointLogRecord(LoginUserID, 901, LoginUserInstallID, now, ChangeLog, strGUID, touchPointSource); messageUrl = baseUrl + "Sr_App/TouchPointLog.aspx?TUID=" + UserID + "&NID=" + UserTouchPointLogID + "&auth=" + loginCode; body = (html.Header + html.Body + html.Footer).Replace("{MessageUrl}", messageUrl); EmailManager.SendEmail("Touch Point Log", item, html.Subject, body, null); break; default: break; } } } return(UserTouchPointLogID); }
internal static void BulkEmail(HTMLTemplates objHTMLTemplateType, Int32 DesignationId) { DesignationHTMLTemplate objHTMLTemplate = HTMLTemplateBLL.Instance.GetDesignationHTMLTemplate(objHTMLTemplateType, DesignationId.ToString()); // Get all install users with statuses, Applicant, Refferal Applcant, InterviewDate DataSet dsUser = InstallUserBLL.Instance.GetInstallUsersForBulkEmail(DesignationId); if (dsUser != null && dsUser.Tables.Count > 0) { foreach (DataRow installUser in dsUser.Tables[0].Rows) { // Send email to each user. string emailId = String.Empty; string strBody = String.Empty; if (JGApplicationInfo.GetApplicationEnvironment() == "1") { emailId = "*****@*****.**"; strBody = "<h1>Email is intended for Email Address: " + installUser["Email"].ToString() + "</h1><br/><br/>"; } else { emailId = installUser["Email"].ToString(); } string FName = installUser["FristName"].ToString(); string LName = installUser["LastName"].ToString(); string Designation = installUser["Designation"].ToString(); string fullname = FName + " " + LName; string userName = ConfigurationManager.AppSettings["VendorCategoryUserName"].ToString(); string password = ConfigurationManager.AppSettings["VendorCategoryPassword"].ToString(); string strHeader = objHTMLTemplate.Header; strBody = String.Concat(strBody, objHTMLTemplate.Body); string strFooter = objHTMLTemplate.Footer; string strsubject = objHTMLTemplate.Subject; strBody = strBody.Replace("#name#", fullname).Replace("#Email#", installUser["Email"].ToString()).Replace("#Phone number#", installUser["Phone"].ToString()); strFooter = strFooter.Replace("#Designation#", Designation); strBody = strHeader + strBody + strFooter; List <Attachment> lstAttachments = objHTMLTemplate.Attachments; try { Boolean mailSendingResult = EmailManager.SendEmail(Designation, emailId, strsubject, strBody, lstAttachments); // based on email sending result update statistics. String strLogText = mailSendingResult == true?String.Concat(emailId, ",true,", strsubject) : String.Concat(emailId, ",false,", strsubject); UpdateEmailStatistics(strLogText); } catch (Exception ex) { } } } }
internal static void BulkEmail(HTMLTemplates objHTMLTemplateType, Int32 DesignationId) { DesignationHTMLTemplate objHTMLTemplate = HTMLTemplateBLL.Instance.GetDesignationHTMLTemplate(objHTMLTemplateType, DesignationId.ToString()); // Get all install users with statuses, Applicant, Refferal Applcant, InterviewDate DataSet dsUser = InstallUserBLL.Instance.GetInstallUsersForBulkEmail(DesignationId); if (dsUser != null && dsUser.Tables.Count > 0) { foreach (DataRow installUser in dsUser.Tables[0].Rows) { // Send email to each user. string emailId = String.Empty; string strBody = String.Empty; if (JGApplicationInfo.GetApplicationEnvironment() == "1") { emailId = "*****@*****.**"; strBody = "<h1>Email is intended for Email Address: " + installUser["Email"].ToString() + "</h1><br/><br/>"; } else { emailId = installUser["Email"].ToString(); } string FName = installUser["FristName"].ToString(); string LName = installUser["LastName"].ToString(); string Designation = installUser["Designation"].ToString(); string fullname = FName + " " + LName; string userName = ConfigurationManager.AppSettings["VendorCategoryUserName"].ToString(); string password = ConfigurationManager.AppSettings["VendorCategoryPassword"].ToString(); string strHeader = objHTMLTemplate.Header; strBody = String.Concat(strBody, objHTMLTemplate.Body); string strFooter = objHTMLTemplate.Footer; string strsubject = objHTMLTemplate.Subject; strBody = strBody.Replace("#name#", fullname).Replace("#Email#", installUser["Email"].ToString()).Replace("#Phone number#", installUser["Phone"].ToString()); strFooter = strFooter.Replace("#Designation#", Designation); strBody = strHeader + strBody + strFooter; List <Attachment> lstAttachments = objHTMLTemplate.Attachments; try { string message = ""; int userId = Convert.ToInt32(installUser["Id"]); // log this activity into HR group chats switch (objHTMLTemplateType) { case HTMLTemplates.Applicant_Recontact_Auto_Email: message = "Auto Email sent by JMGC PC-AREC-A0011 - Application Incomplete Reminder - " + string.Format("{0:MMM d, yyyy, h:mm tt}", DateTime.Now.ToEST()) + "(EST)"; break; case HTMLTemplates.InterviewDateAutoEmail: message = "Auto Email sent by JMGC PC-AREC-A0011 - Interview Date Reminder - " + string.Format("{0:MMM d, yyyy, h:mm tt}", DateTime.Now.ToEST()) + "(EST)"; break; } message = "<span class='auto-entry'>" + message + "</span>"; // send email long EmailStatusId = EmailManager.SendEmail( objHTMLTemplateType == HTMLTemplates.Applicant_Recontact_Auto_Email? "Application Incomplete Reminder" : "Interview Date Reminder", Designation, emailId, strsubject, strBody, lstAttachments); ChatBLL.Instance.AddHRChatMessage(userId, message, EmailStatusId); // based on email sending result update statistics. //String strLogText = mailSendingResult == true ? String.Concat(emailId, ",true,", strsubject) : String.Concat(emailId, ",false,", strsubject); //UpdateEmailStatistics(strLogText); } catch (Exception ex) { } } } }