Example #1
0
        private void SendSMS(string id, string name, string sponserID, string mob, string pass, string email, string username, string Cust_Password, string Cust_Package)
        {
            try
            {
                int    flag   = 0;
                string errmsg = "";
                string otp    = "";
                string Type   = "Registration";
                string Cust_Package_amt;
                //Cust_Package_amt = conCls.getScalerValue("select Product_Price from Product_chart where Product_Code ='" + Cust_Package + "'");
                Cust_Package_amt = "0";
                WebClient client = new WebClient();
                DataSet   ds     = new DataSet();
                ds = conCls.getdataSet("select Baseurl1,Baseurl2 from SMS_Services where Status=1");
                DataTable dt = ds.Tables[0];
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        string baseurl = dt.Rows[0][0].ToString() + mob + dt.Rows[0][1].ToString() + "Congratulations! Dear " + name + ",Thanks For Joining With Us Your userName (" + username + ") and Password: "******" - trans pws :" + pass + " with amount " + Cust_Package_amt + " for detail pls visit aps-mining.com";

                        Stream       data   = client.OpenRead(baseurl);
                        StreamReader reader = new StreamReader(data);
                        string       s      = reader.ReadToEnd();
                        data.Close();
                        reader.Close();
                    }
                }
                ds.Dispose();

                conCls.Insert_OTP_Code(id, Type, out flag, out errmsg, out otp);

                if (flag == 1)
                {
                    string   body     = this.PopulateBody1(id, name, sponserID, mob, pass, email, username, Cust_Password, otp);
                    DateTime letterdt = ConnectionCls.getIndianDateTime();
                    string   dat      = letterdt.ToShortDateString();
                    // Gmail Address from where you send the mail
                    //var fromAddress = ConfigurationManager.AppSettings["smtpsenderEmail"].ToString();
                    // any address where the email will be sending
                    var toAddress = email;
                    //Password of your gmail address
                    //string fromPassword = ConfigurationManager.AppSettings["smtpPassword"].ToString();
                    // Passing the values and make a email formate to display
                    //string subject = "aps-mining.com Welcome to website...!";
                    string subject = "Verification Mail from stack miner";
                    // body = bodyy;
                    MailMessage mailMsg = new MailMessage();
                    // To
                    mailMsg.To.Add(new MailAddress(email));
                    // From
                    mailMsg.From = new MailAddress("*****@*****.**", "Email Verification");
                    //mailMsg.From = new MailAddress("*****@*****.**", " Registration  Detail");
                    //mailMsg.From = new MailAddress(ConfigurationManager.AppSettings["smtpsenderEmail"].ToString(), "Email Verification - aps-mining Pool ");
                    // Subject and multipart/alternative Body
                    mailMsg.Subject = subject;
                    string text = "text body";
                    string html = body;
                    mailMsg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(text, null, MediaTypeNames.Text.Plain));
                    mailMsg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html));
                    // Init SmtpClient and send
                    SmtpClient smtpClient1 = new SmtpClient("smtp.mailgun.org", Convert.ToInt32(587));
                    smtpClient1.EnableSsl = true;
                    System.Net.NetworkCredential credentials1 = new System.Net.NetworkCredential("*****@*****.**", "b5fe91c3d559323d663987a96d22fbcf");
                    smtpClient1.Credentials = credentials1;
                    smtpClient1.Send(mailMsg);
                }
                else
                {
                }
            }
            catch (Exception)
            {
                throw;
            }
        }