Example #1
0
    public static bool SendSMS(string MobileNo, string smsBody)
    {
        BusinessLogicDbTrx objDbTrx = new BusinessLogicDbTrx();
        string             Msg      = smsBody;
        bool      success           = default(bool);
        string    baseurl           = string.Empty;
        WebClient client            = new WebClient();

        try
        {
            string SmsUserID     = System.Web.Configuration.WebConfigurationManager.AppSettings["SmsUserID"].ToString();
            string SmsPassword   = System.Web.Configuration.WebConfigurationManager.AppSettings["SmsPassword"].ToString();
            string SmsSenderName = System.Web.Configuration.WebConfigurationManager.AppSettings["SmsSenderName"].ToString();
            string TestSms       = System.Web.Configuration.WebConfigurationManager.AppSettings["TestSms"].ToString();
            if (TestSms == "TRUE")
            {
                MobileNo = System.Web.Configuration.WebConfigurationManager.AppSettings["TestMobileNo"].ToString();
            }

            try
            {
                baseurl = "http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?username="******"&password="******"&sendername=" + SmsSenderName + "&mobileno=" + MobileNo + "&message=" + smsBody;
                Stream       data   = client.OpenRead(baseurl);
                StreamReader reader = new StreamReader(data);
                Msg = reader.ReadToEnd();
                data.Close();
                reader.Close();
                success = true;
            }
            catch (Exception exc)
            {
                objDbTrx.SaveSystemErrorLog(exc);
            }
        }
        catch (Exception ex)
        {
            objDbTrx.SaveSystemErrorLog(ex);
        }
        return(success);
    }