Exemplo n.º 1
0
        public EmailTemplatesBO GetEmailTemplate(string emailTemplateId)
        {
            EmailTemplatesBO objEmailTemplatesBO = new EmailTemplatesBO();

            try
            {
                var sqlParams = new SqlParameter[1];
                sqlParams[0] = new SqlParameter("@TemplateId", SqlDbType.Int)
                {
                    Value = emailTemplateId
                };

                DataSet _objDataSet = SqlHelper.SqlHelper.ExecuteDataset(SqlHelper.SqlHelper.Connect(), CommandType.StoredProcedure, "Proc_GetEmailTemplateById", sqlParams);
                if (_objDataSet.Tables[0].Rows.Count > 0)
                {
                    var objDataRow = _objDataSet.Tables[0].Rows[0];
                    objEmailTemplatesBO.EmailTemplate = Convert.ToString(objDataRow["EmailTemplate"]);
                    objEmailTemplatesBO.EmailSubject  = Convert.ToString(objDataRow["EmailSubject"]);
                    objEmailTemplatesBO.TemplateId    = Convert.ToInt32(objDataRow["TemplateId"]);
                }
            }
            catch (Exception ex)
            {
                log4netlogger.Error(ex);
            }
            return(objEmailTemplatesBO);
        }
Exemplo n.º 2
0
        public bool Forgotpasswordinfo(string email)
        {
            bool   finalresp = true;
            string response  = objSellffDefaultDAO.Forgotpasswordinfo(email);

            if (!string.IsNullOrEmpty(response))
            {
                EmailTemplatesBO objEmailTemplatesBO = objSellffDefaultDAO.GetEmailTemplate(ConfigurationManager.AppSettings["ForgotPasswordEmail"].ToString());
                try
                {
                    var    resarry   = response.Split('~');
                    string emailBody = objEmailTemplatesBO.EmailTemplate;
                    emailBody = emailBody.Replace("[UserName]", resarry[0]);
                    emailBody = emailBody.Replace("[NewPwd]", resarry[1]);
                    SendSMTPEmail(email, objEmailTemplatesBO, emailBody);
                }
                catch (Exception ex)
                {
                    finalresp = false;
                }
            }
            else
            {
                finalresp = false;
            }
            return(finalresp);
        }
Exemplo n.º 3
0
        public bool SendSMTPEmail(string Email, EmailTemplatesBO objEmailTemplatesBO, string EmailBody)
        {
            String FROM    = ConfigurationManager.AppSettings["FROMEmail"].ToString();
            String SUBJECT = objEmailTemplatesBO.EmailSubject;

            objEmailTemplatesBO.SentTo        = Email;
            objEmailTemplatesBO.EmailTemplate = EmailBody;
            objEmailTemplatesBO.SentFrom      = FROM;
            objEmailTemplatesBO.BCC           = ConfigurationManager.AppSettings["BCCEmail"].ToString();
            // Supply your SMTP credentials below. Note that your SMTP credentials are different from your AWS credentials.
            String SMTP_USERNAME = ConfigurationManager.AppSettings["SMTPUsername"].ToString();  // Replace with your SMTP username.
            String SMTP_PASSWORD = ConfigurationManager.AppSettings["SMTPPassword"].ToString();  // Replace with your SMTP password.

            // Amazon SES SMTP host name. This example uses the US West (Oregon) region.
            String HOST = ConfigurationManager.AppSettings["SMTPServer"].ToString();

            // The port you will connect to on the Amazon SES SMTP endpoint. We are choosing port 587 because we will use
            // STARTTLS to encrypt the connection.
            int PORT = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"].ToString());

            // Create an SMTP client with the specified host name and port.
            using (System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(HOST, PORT))
            {
                // Create a network credential with your SMTP user name and password.
                client.Credentials = new System.Net.NetworkCredential(SMTP_USERNAME, SMTP_PASSWORD);

                // Use SSL when accessing Amazon SES. The SMTP session will begin on an unencrypted connection, and then
                // the client will issue a STARTTLS command to upgrade to an encrypted connection using SSL.
                client.EnableSsl = Convert.ToBoolean(ConfigurationManager.AppSettings["ISSMTPSSL"].ToString());

                System.Net.Mail.MailMessage Message = new System.Net.Mail.MailMessage(FROM, Email);
                Message.Subject    = SUBJECT;
                Message.Body       = EmailBody;
                Message.IsBodyHtml = true;
                if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["BCCEmail"].ToString()))
                {
                    System.Net.Mail.MailAddress bcc = new System.Net.Mail.MailAddress(Convert.ToString(ConfigurationManager.AppSettings["BCCEmail"].ToString()));

                    Message.Bcc.Add(bcc);
                }
                // Message.CC = Convert.ToString(ConfigurationManager.AppSettings["CCEmail"].ToString());
                // Send the email.
                try
                {
                    client.Send(Message);
                    objEmailTemplatesBO.IsSent = true;
                }
                catch (Exception ex)
                {
                    objEmailTemplatesBO.IsSent        = false;
                    objEmailTemplatesBO.StatusMessage = ex.Message;
                }
                finally
                {
                    objSellffDefaultDAO.SaveEmailLogDetails(objEmailTemplatesBO);
                }
            }
            return(true);
        }
Exemplo n.º 4
0
        public void SaveEmailLogDetails(EmailTemplatesBO objEmailTemplatesBO)
        {
            try
            {
                var sqlParams = new SqlParameter[10];
                sqlParams[0] = new SqlParameter("@TemplateId", SqlDbType.Int)
                {
                    Value = objEmailTemplatesBO.TemplateId
                };
                sqlParams[1] = new SqlParameter("@EmailSubject", SqlDbType.VarChar)
                {
                    Value = objEmailTemplatesBO.EmailSubject
                };
                sqlParams[2] = new SqlParameter("@EmailTemplate", SqlDbType.VarChar)
                {
                    Value = objEmailTemplatesBO.EmailTemplate
                };
                sqlParams[3] = new SqlParameter("@SentFrom", SqlDbType.VarChar)
                {
                    Value = objEmailTemplatesBO.SentFrom
                };
                sqlParams[4] = new SqlParameter("@SentTo", SqlDbType.VarChar)
                {
                    Value = objEmailTemplatesBO.SentTo
                };
                sqlParams[5] = new SqlParameter("@CC", SqlDbType.VarChar)
                {
                    Value = objEmailTemplatesBO.CC
                };
                sqlParams[6] = new SqlParameter("@BCC", SqlDbType.VarChar)
                {
                    Value = objEmailTemplatesBO.BCC
                };
                sqlParams[7] = new SqlParameter("@UserId", SqlDbType.Int)
                {
                    Value = objEmailTemplatesBO.UserId
                };
                sqlParams[8] = new SqlParameter("@StatusMessage", SqlDbType.VarChar)
                {
                    Value = objEmailTemplatesBO.StatusMessage
                };
                sqlParams[9] = new SqlParameter("@IsSent", SqlDbType.Bit)
                {
                    Value = objEmailTemplatesBO.IsSent
                };

                SqlHelper.SqlHelper.ExecuteNonQuery(SqlHelper.SqlHelper.Connect(), CommandType.StoredProcedure, "Proc_SaveEmailLog", sqlParams);
            }
            catch (Exception ex)
            {
                log4netlogger.Error(ex);
            }
        }
Exemplo n.º 5
0
        public bool UpdateUserInvitationSentDate(string InviteGuid)
        {
            InviteUsersBO    objResponseBO       = objSellffDefaultDAO.UpdateUserInvitationSentDate(InviteGuid);
            EmailTemplatesBO objEmailTemplatesBO = objSellffDefaultDAO.GetEmailTemplate(ConfigurationManager.AppSettings["InviteEmail"].ToString());

            try
            {
                SendEmail(objResponseBO.EmailId, objResponseBO.Name, objResponseBO.InviteGuid, ConfigurationManager.AppSettings["InitationURL"].ToString(), objEmailTemplatesBO, objResponseBO.RefereUserName);
            }
            catch (Exception ex)
            {
            }
            return(true);
        }
Exemplo n.º 6
0
        public AuthenticationBO RegisterSellffUserInfo(AuthenticationBO objAuthenticationBO)
        {
            AuthenticationBO objResponseBO = objSellffDefaultDAO.RegisterSellffUserInfo(objAuthenticationBO);

            if (objAuthenticationBO.InviteGuid == "")
            {
                EmailTemplatesBO objEmailTemplatesBO = objSellffDefaultDAO.GetEmailTemplate(ConfigurationManager.AppSettings["RegEmail"].ToString());
                try
                {
                    SendEmail(objResponseBO.Email, objResponseBO.DisplayName, objResponseBO.InviteUniqueId, ConfigurationManager.AppSettings["ActivateAppDomain"].ToString(), objEmailTemplatesBO, "");
                }
                catch (Exception ex)
                {
                }
            }
            return(objResponseBO);
        }