Exemplo n.º 1
0
        public async Task sendemail(AuthenticationParameters model)
        {
            //var message = new MailMessage();
            //  var ToEmailId = AuthenticationServices.sendmail(model._user_code);
            //message.To.Add(new MailAddress(ToEmailId));
            //message.From = new MailAddress("*****@*****.**");
            //message.Subject = "Reset Password";
            //message.Body = "Reset Password Link http://localhost:4200/ResetPassword?Usercode=" + model._user_code;
            //message.IsBodyHtml = true;
            //using (var smtp = new SmtpClient("smtp.gmail.com", 587))
            //{
            //    smtp.Host = "10.2.202.42";
            //    smtp.Credentials = new NetworkCredential("*****@*****.**", "Mumbai@12345");
            //    smtp.EnableSsl = true;
            //    //smtp.Send(message);
            //    await smtp.SendMailAsync(message);
            //    await Task.FromResult(0);

            //below code commented by Kirti on 16-06-2021 for reset password mail send functioanlity
            //var message = new MailMessage();

            //message.To.Add(new MailAddress(ToEmailId));
            //message.From = new MailAddress("*****@*****.**");
            //message.Subject = "Reset Password";
            //message.Body = "Reset Password Link http://localhost:4200/ResetPassword";
            //message.IsBodyHtml = true;
            //using (var smtp = new SmtpClient("smtp.gmail.com", 587))
            //{

            //    //smtp.Credentials = new NetworkCredential("*****@*****.**", "Mumbai@12345");
            //    smtp.EnableSsl = true;
            //    //smtp.Send(message);
            //    await smtp.SendMailAsync(message);
            //    await Task.FromResult(0);

            ////}

            //}

            try
            {
                var ToEmailId             = AuthenticationServices.sendmail(model._user_code);
                EmailSendingProperties EP = new EmailSendingProperties();
                EP.SendTo     = new List <EmailToCCParameters>();
                EP.SendCC     = new List <EmailToCCParameters>();
                EP.Attachment = new List <EmailAttachmentParameters>();
                EmailToCCParameters To = new EmailToCCParameters();
                To.email_id = ToEmailId;
                EP.SendTo.Add(To);
                EP.subject = "Reset Password";
                EP.body    = "Reset Password Link http://localhost:4200/ResetPassword";
                EmailSender ES = new EmailSender();
                ES.sendEmail(EP);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
 public static void EmailSendTest()
 {
     try
     {
         EmailSendingProperties EP = new EmailSendingProperties();
         EP.SendTo     = new List <EmailToCCParameters>();
         EP.Attachment = new List <EmailAttachmentParameters>();
         EmailToCCParameters To = new EmailToCCParameters();
         To.email_id = "*****@*****.**";
         EP.SendTo.Add(To);
         EP.SendCC = new List <EmailToCCParameters>();
         EmailToCCParameters CC = new EmailToCCParameters();
         CC.email_id = "*****@*****.**";
         EP.SendCC.Add(CC);
         EP.subject = "test mail from system";
         EP.body    = "Mail send for test do not reply";
         EmailSender ES = new EmailSender();
         ES.sendEmail(EP);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
        public static List <commanmessges> Email_Sending_Details(int _dh_header_id, int _is_shared)
        {
            List <commanmessges> _commanmessges = new List <commanmessges>();

            try
            {
                using (MySqlConnection conn = new MySqlConnection(connectionString))
                {
                    MySqlDataAdapter DA  = new MySqlDataAdapter();
                    MySqlCommand     cmd = new MySqlCommand("sp_getEmail_Sending_Details", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@_dh_header_id", MySqlDbType.UInt32).Value = _dh_header_id;
                    cmd.Parameters.Add("@_is_shared", MySqlDbType.UInt32).Value    = _is_shared;
                    DA.SelectCommand = cmd;
                    cmd.Connection   = new MySqlConnection(connectionString);
                    DataSet ds = new DataSet();
                    DA.Fill(ds);

                    DataSet rds = ds.GetTableName();

                    if (rds.Tables["replaceemailcontent"] != null)
                    {
                        EmailSendingProperties ep = new EmailSendingProperties();
                        ep.SendTo     = new List <EmailToCCParameters>();
                        ep.SendCC     = new List <EmailToCCParameters>();
                        ep.Attachment = new List <EmailAttachmentParameters>();
                        if (rds.Tables["EmailBody"] != null)
                        {
                            foreach (DataRow Dr in rds.Tables["EmailBody"].Rows)
                            {
                                string email_subject = Dr["email_subject"].ToString();
                                string email_body    = Dr["email_body"].ToString();
                                foreach (DataRow DrReplace in rds.Tables["replaceemailcontent"].Rows)
                                {
                                    foreach (DataColumn DC in rds.Tables["replaceemailcontent"].Columns)
                                    {
                                        email_subject = email_subject.Replace("#" + DC.ColumnName.ToString(), DrReplace[DC.ColumnName].ToString());
                                        email_body    = email_body.Replace("#" + DC.ColumnName.ToString(), DrReplace[DC.ColumnName].ToString());
                                    }
                                }

                                ep.subject = email_subject;
                                ep.body    = email_body;
                            }

                            if (rds.Tables["ToEmail"] != null)
                            {
                                foreach (DataRow ToRow in ds.Tables["ToEmail"].Rows)
                                {
                                    EmailToCCParameters To = new EmailToCCParameters();
                                    To.email_id = ToRow["ToEmailId"].ToString();
                                    ep.SendTo.Add(To);
                                }
                            }


                            if (rds.Tables["CCEmail"] != null)
                            {
                                foreach (DataRow ToRow in ds.Tables["CCEmail"].Rows)
                                {
                                    EmailToCCParameters To = new EmailToCCParameters();
                                    To.email_id = ToRow["CcEmailId"].ToString();
                                    ep.SendCC.Add(To);
                                }
                            }


                            EmailSender ES = new EmailSender();
                            ES.sendEmail(ep);
                        }
                        else
                        {
                            commanmessges cm = new commanmessges();
                            cm.message = "failure in sending mail";
                            cm.status  = "failure";
                            _commanmessges.Add(cm);
                        }

                        if (rds.Tables["PPLInit_ToEmail"] != null)
                        {
                            EmailSendingProperties ep1 = new EmailSendingProperties();
                            ep1.SendTo     = new List <EmailToCCParameters>();
                            ep1.SendCC     = new List <EmailToCCParameters>();
                            ep1.Attachment = new List <EmailAttachmentParameters>();
                            if (rds.Tables["PPLInit_EmailBody"] != null)
                            {
                                foreach (DataRow Dr in rds.Tables["PPLInit_EmailBody"].Rows)
                                {
                                    string email_subject = Dr["email_subject"].ToString();
                                    string email_body    = Dr["email_body"].ToString();
                                    foreach (DataRow DrReplace in rds.Tables["replaceemailcontent"].Rows)
                                    {
                                        foreach (DataColumn DC in rds.Tables["replaceemailcontent"].Columns)
                                        {
                                            email_subject = email_subject.Replace("#" + DC.ColumnName.ToString(), DrReplace[DC.ColumnName].ToString());
                                            email_body    = email_body.Replace("#" + DC.ColumnName.ToString(), DrReplace[DC.ColumnName].ToString());
                                        }
                                    }

                                    ep1.subject = email_subject;
                                    ep1.body    = email_body;
                                }

                                if (rds.Tables["PPLInit_ToEmail"] != null)
                                {
                                    foreach (DataRow ToRow in ds.Tables["PPLInit_ToEmail"].Rows)
                                    {
                                        EmailToCCParameters To = new EmailToCCParameters();
                                        To.email_id = ToRow["ToEmailId"].ToString();
                                        ep1.SendTo.Add(To);
                                    }
                                }
                            }

                            EmailSender ES1 = new EmailSender();
                            ES1.sendEmail(ep1);
                        }
                    }
                    else
                    {
                        commanmessges cm = new commanmessges();
                        cm.message = "failure in sending mail";
                        cm.status  = "failure";
                        _commanmessges.Add(cm);
                    }


                    //return JsonConvert.SerializeObject(rds, Formatting.Indented); ;
                    return(_commanmessges);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }