Ejemplo n.º 1
0
        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs
            Exception ex = Server.GetLastError();

            DALError.LogError("GlobalError", ex);
            Server.ClearError();
        }
Ejemplo n.º 2
0
        private static bool SendPasswordResetEmail(string ToEmail, string UserName, string UniqueId)
        {
            bool   issent            = false;
            String EmailTemplatepath = Convert.ToString(System.Web.HttpContext.Current.Server.MapPath("~/html/ForgetPasswordEmailHtmlFile.html"));
            String EmailTemplate     = String.Empty;
            String ResetLink         = System.Web.HttpContext.Current.Request.Url.Host + "/Login/LoginRegistration?uid=" + UniqueId;

            EmailTemplate = Jobsportal.Common.ReadHtmlFile(EmailTemplatepath);
            EmailTemplate = EmailTemplate.Replace("@@UserName@@", UserName);
            EmailTemplate = EmailTemplate.Replace("@@ResetLink@@", ResetLink);
            String MSubject = "Reset Password";

            EmailServer emailconfigdata = EmailServer.GetEmailConfiguration();
            SmtpClient  client          = new SmtpClient();

            client.Port                  = Convert.ToInt32(emailconfigdata.Port);
            client.Host                  = emailconfigdata.Host;
            client.EnableSsl             = emailconfigdata.SSL;
            client.Timeout               = 10000;
            client.DeliveryMethod        = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Credentials           = new System.Net.NetworkCredential(emailconfigdata.Email, emailconfigdata.Password);

            MailMessage mm = new MailMessage(emailconfigdata.Email, ToEmail, MSubject, EmailTemplate);

            mm.BodyEncoding = UTF8Encoding.UTF8;
            mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
            mm.Subject    = MSubject;
            mm.Body       = EmailTemplate;
            mm.IsBodyHtml = true;

            try
            {
                client.Send(mm);
                issent = true;
            }
            catch (Exception ex)
            {
                DALError.LogError("Login.SendPasswordResetEmail", ex);
            }
            return(issent);
        }
Ejemplo n.º 3
0
        public static String ReadHtmlFile(String htmlFilePath)
        {
            StringBuilder store = new StringBuilder();

            try
            {
                using (StreamReader htmlReader = new StreamReader(htmlFilePath))
                {
                    String line;
                    while ((line = htmlReader.ReadLine()) != null)
                    {
                        store.Append(line);
                    }
                }
            }
            catch (Exception ex) {
                DALError.LogError("Common.ReadHtmlFile", ex);
            }

            return(store.ToString());
        }
Ejemplo n.º 4
0
        private void SendWelcomeEmail(string ToEmail, string UserName)
        {
            String EmailTemplatepath = Convert.ToString(Server.MapPath("~/html/Welcome.html"));
            String EmailTemplate     = String.Empty;

            EmailTemplate = Jobsportal.Common.ReadHtmlFile(EmailTemplatepath);
            EmailTemplate = EmailTemplate.Replace("@@UserName@@", UserName);
            String MSubject = "Welcome to Drashta Infotech";

            EmailServer emailconfigdata = EmailServer.GetEmailConfiguration();
            SmtpClient  client          = new SmtpClient();

            client.Port                  = Convert.ToInt32(emailconfigdata.Port);
            client.Host                  = emailconfigdata.Host;
            client.EnableSsl             = emailconfigdata.SSL;
            client.Timeout               = 10000;
            client.DeliveryMethod        = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Credentials           = new System.Net.NetworkCredential(emailconfigdata.Email, emailconfigdata.Password);

            MailMessage mm = new MailMessage(emailconfigdata.Email, ToEmail, MSubject, EmailTemplate);

            mm.BodyEncoding = UTF8Encoding.UTF8;
            mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
            mm.Subject    = MSubject;
            mm.Body       = EmailTemplate;
            mm.IsBodyHtml = true;

            try
            {
                client.Send(mm);
            }
            catch (Exception ex)
            {
                DALError.LogError("Login.SendWelcomeEmail", ex);
            }
        }
Ejemplo n.º 5
0
        public void SendEmailToCandidate(int jobno, string jobkeywords, string host)
        {
            DataSet Candidate = DAL.Utility.CandidateData();

            string[] jobwords = jobkeywords.Split(' ');
            if (Candidate.Tables.Count > 0)
            {
                if (Candidate.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in Candidate.Tables[0].Rows)
                    {
                        string   PerKeyword      = dr["PerKeyword"].ToString();
                        string[] perwords        = PerKeyword.Split(' ');
                        string   mailcommonwords = string.Empty;
                        string   Email           = dr["Email"].ToString();
                        string   Name            = dr["Name"].ToString();
                        var      commonwords     = jobwords.Intersect(perwords);
                        foreach (string word in commonwords)
                        {
                            mailcommonwords = mailcommonwords + "," + word;
                        }

                        if (!string.IsNullOrEmpty(mailcommonwords))
                        {
                            String EmailTemplatepath = Convert.ToString(Server.MapPath("~/html/JobNotifcation.html"));
                            String EmailTemplate     = String.Empty;
                            EmailTemplate = Jobsportal.Common.ReadHtmlFile(EmailTemplatepath);
                            EmailTemplate = EmailTemplate.Replace("@@UserName@@", Name);
                            EmailTemplate = EmailTemplate.Replace("@@ApplyLink@@", host + "/jobs/JobDetails?JobNo=" + jobno);
                            EmailTemplate = EmailTemplate.Replace("@@mailcommonwords@@", mailcommonwords);
                            EmailServer emailconfigdata = EmailServer.GetEmailConfiguration();
                            SmtpClient  client          = new SmtpClient();
                            client.Port                  = Convert.ToInt32(emailconfigdata.Port);
                            client.Host                  = emailconfigdata.Host;
                            client.EnableSsl             = emailconfigdata.SSL;
                            client.Timeout               = 10000;
                            client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                            client.UseDefaultCredentials = false;
                            client.Credentials           = new System.Net.NetworkCredential(emailconfigdata.Email, emailconfigdata.Password);

                            // string mailbody = "A New job has been posted.  You can apply the job using below link" + Environment.NewLine + System.Web.HttpContext.Current.Request.Url.Host + "/jobs/ JobDetails ? JNo = " + jobno + Environment.NewLine + "You are receiving mail because your profile contains these words " +"<b>"+ mailcommonwords+"</b>"+Environment.NewLine+ "Regards,"+ Environment.NewLine+"Drashta Infotech Team";
                            //string mailbody = "A New job has been posted.  You can apply the job using below link" + Environment.NewLine + "http://jobhelperstage.drashtainfotech.com/" + "/jobs/ JobDetails ? JNo = " + jobno + Environment.NewLine + "You are receiving mail because your profile contains these words " + "<b>" + mailcommonwords + "</b>" + Environment.NewLine + "Regards," + Environment.NewLine + "Drashta Infotech Team";
                            MailMessage mm = new MailMessage(emailconfigdata.Email, Email, "Notification from  Drashta Infotech Job Helper portal ", EmailTemplate);

                            mm.BodyEncoding = UTF8Encoding.UTF8;
                            mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                            mm.IsBodyHtml = true;

                            try
                            {
                                client.Send(mm);
                            }
                            catch (Exception ex)
                            {
                                DALError.LogError("Jobs.SendEmailToCandidate", ex);
                            }
                        }
                    }
                }
            }
        }