Exemple #1
0
 public DataSet GetMailInfo(EmailActivityBOL objEmailActivityBOL)
 {
     SqlParameter[] param = new SqlParameter[4];
     param[0]       = new SqlParameter("@ToID", SqlDbType.VarChar);
     param[0].Value = objEmailActivityBOL.ToID;
     param[1]       = new SqlParameter("@FromID", SqlDbType.Int);
     param[1].Value = objEmailActivityBOL.FromID;
     param[2]       = new SqlParameter("@CCID", SqlDbType.VarChar);
     param[2].Value = objEmailActivityBOL.CCID;
     param[3]       = new SqlParameter("@EmailTemplateName", SqlDbType.VarChar);
     param[3].Value = objEmailActivityBOL.EmailTemplateName;
     return(dsEmailActivityDAL = SqlHelper.ExecuteDataset(AppConfiguration.ConnectionString, CommandType.StoredProcedure, "sp_GetMailInfo", param));
 }
Exemple #2
0
        private void SendSubmitMail(int loggedinUser, int empId, string msg)
        {
            var objApr = new Appraisal();
            EmailActivityBOL objEmailActivityBOL = new EmailActivityBOL();
            DataSet          dsGetMailInfo       = new DataSet();
            EmailActivityBLL objEmailActivityBLL = new EmailActivityBLL();
            EmailActivity    objEmailActivity    = new EmailActivity();

            char[] separator = new char[] { ';' };

            if (msg.ToLower().Contains("appraisal submitted to closure"))
            {
                dsGetMailInfo = objApr.GetMailDetails(loggedinUser, empId, "complete");
            }
            else
            {
                dsGetMailInfo = objApr.GetMailDetails(loggedinUser, empId, "");
            }

            objEmailActivityBOL.FromAddress = (dsGetMailInfo.Tables[0].Rows[0]["FromAddress"].ToString());
            objEmailActivityBOL.CCID        = ConfigurationManager.AppSettings["HR-ADMIN"].ToString();

            //string[] cc = ConfigurationManager.AppSettings["HR-ADMIN"].ToString().Split(';');

            //for (int i = 0; i < cc.Length; i++)
            //{
            //    if (cc[i] != "")
            //    {
            //        objEmailActivityBOL.CCAddress[i] =cc[i];
            //    }
            //}

            objEmailActivityBOL.EmailTemplateName = (dsGetMailInfo.Tables[0].Rows[0]["EmailTemplateName"].ToString());

            // dsGetMailInfo = objEmailActivityBLL.GetMailInfo(objEmailActivityBOL);
            objEmailActivityBOL.ToAddress = (dsGetMailInfo.Tables[0].Rows[0]["ToAddress"].ToString()).Split(separator);
            objEmailActivityBOL.Subject   = (dsGetMailInfo.Tables[0].Rows[0]["EmailSubject"].ToString());
            objEmailActivityBOL.Body      = (dsGetMailInfo.Tables[0].Rows[0]["EmailBody"].ToString());

            try
            {
                objEmailActivity.SendSubmitMail(objEmailActivityBOL, (dsGetMailInfo.Tables[0].Rows[0]["toName"].ToString()), (dsGetMailInfo.Tables[0].Rows[0]["EmployeeName"].ToString()), (dsGetMailInfo.Tables[0].Rows[0]["EmployeeCode"].ToString()));
            }
            catch (System.Exception ex)
            {
                throw new Exception("Appraisal Submitted to next stage but failed to send mail.");
            }
        }
Exemple #3
0
        private void SendInitiationMail(List <ProbableList> lstAppr)
        {
            try
            {
                EmailActivityBOL objEmailActivityBOL = new EmailActivityBOL();
                DataSet          dsGetMailInfo       = new DataSet();
                EmailActivityBLL objEmailActivityBLL = new EmailActivityBLL();
                EmailActivity    objEmailActivity    = new EmailActivity();

                char[] separator  = new char[] { ';' };
                string failureMsg = "\r\nCandidates initiated but mail sending failed for : ";
                foreach (ProbableList itemAppr in lstAppr)
                {
                    objEmailActivityBOL.ToID = objEmailActivityBOL.ToID + itemAppr.EID.ToString() + ";";
                    //objApr.getMailID(itemAppr.EID);
                }
                objEmailActivityBOL.FromAddress       = "*****@*****.**";
                objEmailActivityBOL.CCID              = ConfigurationManager.AppSettings["HR-ADMIN"].ToString();
                objEmailActivityBOL.EmailTemplateName = "Appraisal Initiate";

                dsGetMailInfo = objEmailActivityBLL.GetMailInfo(objEmailActivityBOL);
                objEmailActivityBOL.ToAddress = (dsGetMailInfo.Tables[0].Rows[0]["ToAddress"].ToString()).Split(separator);
                objEmailActivityBOL.Subject   = (dsGetMailInfo.Tables[0].Rows[0]["EmailSubject"].ToString());
                objEmailActivityBOL.Body      = (dsGetMailInfo.Tables[0].Rows[0]["EmailBody"].ToString());
                objEmailActivityBOL.CCAddress = (dsGetMailInfo.Tables[0].Rows[0]["CCAddress"].ToString()).Split(separator);

                try
                {
                    objEmailActivity.SendMail(objEmailActivityBOL);
                }
                catch (System.Exception ex)
                {
                    failureMsg = failureMsg + objEmailActivityBOL.ToAddress;
                }
            }
            catch (Exception ex) { throw ex; }
        }
Exemple #4
0
 public DataSet GetMailInfo(EmailActivityBOL objEmailActivityBOL)
 {
     return(dsEmailActivityBLL = objEmailActivityDAL.GetMailInfo(objEmailActivityBOL));
 }
Exemple #5
0
        public void SendMail(EmailActivityBOL objEmailActivityBOL)
        {
            for (int i = 0; i < objEmailActivityBOL.ToAddress.Length; i++)
            {
                if (objEmailActivityBOL.ToAddress[i] != "")
                {
                    String body = string.Empty;
                    int    pos  = objEmailActivityBOL.ToAddress[i].IndexOf(".");
                    string name = objEmailActivityBOL.ToAddress[i].Substring(0, pos);
                    name = name.ToUpper();
                    //if mail not raised by RRF Requestor
                    if (objEmailActivityBOL.Subject != "Aprrove RRF")
                    {
                        body = objEmailActivityBOL.Body.Replace("##EmployeeName##", name);
                    }

                    MailMessage objMailMessage = new MailMessage();
                    objMailMessage.From = new MailAddress(objEmailActivityBOL.FromAddress);
                    objMailMessage.To.Add(new MailAddress(objEmailActivityBOL.ToAddress[i]));
                    objMailMessage.Subject = objEmailActivityBOL.Subject;

                    //objMailMessage.IsBodyHtml = true;
                    //for (int k = 0; k < objEmailActivityBOL.CCAddress.Length; k++)
                    //    objMailMessage.CC.Add(new MailAddress(objEmailActivityBOL.CCAddress[k]));
                    SmtpClient smtpClient = new SmtpClient(ConfigurationSettings.AppSettings["SMTPServerName"].ToString());
                    smtpClient.UseDefaultCredentials = false;
                    //SmtpClient smtpClient = new SmtpClient("webmail.in.v2solutions.com");

                    if (!objEmailActivityBOL.ToAddress[i].ToString().Contains("@v2solutions.com"))
                    {
                        //objMailMessage.From = new MailAddress("*****@*****.**");
                        objMailMessage.From = new MailAddress(ConfigurationSettings.AppSettings["MailAddress"].ToString());
                        body = body.Replace("##RRFNO##", objEmailActivityBOL.RRFNo.ToString());
                        body = body.Replace("##skills##", objEmailActivityBOL.skills.ToString());
                        body = body.Replace("##designation##", objEmailActivityBOL.Position.ToString());
                        body = body.Replace("##EmployeeName##", objEmailActivityBOL.CandidateName);
                        smtpClient.Credentials = new System.Net.NetworkCredential(ConfigurationSettings.AppSettings["SMTPUserName"].ToString(), ConfigurationSettings.AppSettings["SMTPPassword"].ToString());//("v2system", "mail_123");
                    }
                    else
                    {
                        objMailMessage.From = new MailAddress(objEmailActivityBOL.FromAddress);
                        body = objEmailActivityBOL.Body.Replace("##RRFNO##", objEmailActivityBOL.RRFNo.ToString());

                        body = body.Replace("##skills##", objEmailActivityBOL.skills.ToString());
                        body = body.Replace("##designation##", objEmailActivityBOL.Position.ToString());
                        body = body.Replace("##Candidate name##", objEmailActivityBOL.CandidateName);
                        if (objEmailActivityBOL.EmailTemplateName != "Accept RRF")
                        {
                            for (int k = 0; k < objEmailActivityBOL.CCAddress.Length; k++)
                            {
                                objMailMessage.CC.Add(new MailAddress(objEmailActivityBOL.CCAddress[k]));
                            }
                        }
                        smtpClient.Credentials = new System.Net.NetworkCredential(ConfigurationSettings.AppSettings["SMTPUserName"].ToString(), ConfigurationSettings.AppSettings["SMTPPassword"].ToString());//("v2system", "mail_123");
                    }
                    objMailMessage.IsBodyHtml = true;
                    objMailMessage.Body       = body;
                    smtpClient.Port           = Convert.ToInt32(ConfigurationSettings.AppSettings["PortNumber"].ToString());
                    smtpClient.EnableSsl      = true;
                    smtpClient.Send(objMailMessage);
                }
            }
        }
Exemple #6
0
        public void SendSubmitMail(EmailActivityBOL objEmailActivityBOL, string ToName, string empName, string empCode)
        {
            try
            {
                for (int i = 0; i < objEmailActivityBOL.ToAddress.Length; i++)
                {
                    if (objEmailActivityBOL.ToAddress[i] != "")
                    {
                        MailMessage objMailMessage = new MailMessage();

                        if (objEmailActivityBOL.CCAddress != null)
                        {
                            for (int j = 0; j < objEmailActivityBOL.CCAddress.Length; j++)
                            {
                                if (objEmailActivityBOL.CCAddress[j] != "")
                                {
                                    objMailMessage.CC.Add(new MailAddress(objEmailActivityBOL.CCAddress[j]));
                                }
                            }
                        }


                        //objMailMessage.Bcc.Add(new MailAddress(objEmailActivityBOL.ToAddress[i]));
                        objMailMessage.To.Add(new MailAddress(objEmailActivityBOL.ToAddress[i]));

                        string reciepient = Convert.ToString(ToName.Split(';')[i]);

                        //##EmployeeName## (##Code##)   ##toname##

                        objMailMessage.From = new MailAddress(objEmailActivityBOL.FromAddress);

                        objEmailActivityBOL.Subject = objEmailActivityBOL.Subject.Replace("##EmployeeName##", empName).Replace("##Code##", empCode);

                        string tempBody = objEmailActivityBOL.Body;

                        objEmailActivityBOL.Body = objEmailActivityBOL.Body.Replace("##EmployeeName##", empName).Replace("##Code##", empCode).Replace("##toname##", reciepient);


                        objMailMessage.Subject = objEmailActivityBOL.Subject;
                        objMailMessage.Subject = objEmailActivityBOL.Subject.Replace("\r\n", " ");

                        SmtpClient smtpClient = new SmtpClient(ConfigurationSettings.AppSettings["SMTPServerName"].ToString());
                        smtpClient.UseDefaultCredentials = false;

                        smtpClient.Credentials = new System.Net.NetworkCredential(ConfigurationSettings.AppSettings["SMTPUserName"].ToString(), ConfigurationSettings.AppSettings["SMTPPassword"].ToString());//("v2system", "mail_123");

                        objMailMessage.IsBodyHtml = true;
                        objMailMessage.Body       = objEmailActivityBOL.Body;
                        smtpClient.Port           = Convert.ToInt32(ConfigurationSettings.AppSettings["PortNumber"].ToString());
                        smtpClient.EnableSsl      = true;
                        smtpClient.Send(objMailMessage);

                        objEmailActivityBOL.Body = tempBody;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }