locked
how to send sms from asp.net application to mobile RRS feed

  • Question

  • User-922170241 posted

     hi to all,

    thanks in advance,

    please give me code for  sending  sms from asp.net  application to mobiles,

    Saturday, December 8, 2007 2:48 AM

Answers

  • User-2014425070 posted

    Hi,

    Basically you require a SMS Gateway through which you have to send your message, which would be a paid service to which you have to subscribe. My suggestion would be to create a common interface for mail, text messages etc which would contain methods like "SendMessage","ConstructMessage" etc and  implement those. Usually your application would require to consume a webservice provided by the gateway service, but I believe there are some other methods in practice as well. The following links might be of help to you -

    http://forums.asp.net/t/57735.aspx

    http://www.gotocode.com/art.asp?art_id=66  - contains the basic code structure

    You can download this free component and check it out (not sure about licensing terms, so read their terms if you want to use it commercially) - http://www.intellisoftware.co.uk/sms-gateway/dotnet-component/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 9, 2007 5:29 AM

All replies

  • User-2014425070 posted

    Hi,

    Basically you require a SMS Gateway through which you have to send your message, which would be a paid service to which you have to subscribe. My suggestion would be to create a common interface for mail, text messages etc which would contain methods like "SendMessage","ConstructMessage" etc and  implement those. Usually your application would require to consume a webservice provided by the gateway service, but I believe there are some other methods in practice as well. The following links might be of help to you -

    http://forums.asp.net/t/57735.aspx

    http://www.gotocode.com/art.asp?art_id=66  - contains the basic code structure

    You can download this free component and check it out (not sure about licensing terms, so read their terms if you want to use it commercially) - http://www.intellisoftware.co.uk/sms-gateway/dotnet-component/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 9, 2007 5:29 AM
  • User1565039490 posted

    This code works in Windows Mobile 6:

    SmsMessage sm= new SmsMessage("destination phone number","messagetext");
    sm.RequestDeliveryReport = true;
    sm.Send();

    Thursday, December 20, 2007 2:58 PM
  • User-128667414 posted

    hi, besides Microsoft Visual Studio 2008 and GSM modem, what kind of software or service do i need to buy or download to develop the pc-based SMS application?

     Waiting for ur reply. Thx!

    Elaine Gu from CHINA

    Monday, February 25, 2008 1:31 AM
  • User641584537 posted

    Hi this is manohar, i tried to send sms from the webservices (www.webservicex.net and www.webservicex.com) but this is not at all working properly.

     

     If you having the code to send sms from asp.net then please forwad me to manohar_vakkala@yahoo.com .

     

     

    Monday, November 24, 2008 10:45 AM
  • User970350993 posted

    Hi friends

    did u get the working code for that sending sms ? could u send me that url ? i have to also implement in one project.

    Thursday, March 12, 2009 10:12 AM
  • User-807622823 posted
    Here is a good article on Sending SMS in C# using AT Command GSM Modem. There is a Sample Project for Download. If you need more information on this please feel free to ask to CodeGlobe Contributors
     
    http://codeglobe.blogspot.com/2009/02/sending-sms-in-cnet-using-gsm-modem-and.html
     
    Also there is AT Command Set of Sony Ericssion  
     
    http://codeglobe.blogspot.com/2009/02/at-command-set-for-sony-ericsson.html
     

    Thursday, April 23, 2009 6:22 AM
  • User689809150 posted

     Hi,

     I know an SMS gateway software, you can use it from .net.  It can be installed on a PC and it simplifies most of the tasks when you want to create such a solution. You need a GSM modem or IP connection for the sending. Here is the URL:

    www.ozekisms.com

    Monday, May 4, 2009 9:58 AM
  • User970350993 posted

    yes. i have checked that link. i had solved that problem using "clickat tell" gateway. That is very nice. there is no need to install any software.

    Tuesday, May 5, 2009 12:50 AM
  • User525756525 posted

    Hi Chandradev,

    i have to implement same application in my project, can you please send me the code.

    i am trying it from last week but not succed yet..

    thanx. 

     

     

    Tuesday, May 5, 2009 8:53 AM
  • User970350993 posted

    Hi rahul

    That is so simple. At first time i also took so much time. But i solved that problem. Send me  email id i will send exact code.

     

    Thursday, May 7, 2009 5:43 AM
  • User-1174271348 posted

     Hi , Please tell me how to send an SMS from my application . What steps i need to take .....?Any free carriers in india ....?

    Monday, May 11, 2009 2:28 AM
  • User970350993 posted

    hi

    For that you have to register on bulk sms service provider website.Then they will give API source code for developer and you will also get some free sms for testing. I have tested on "clickatell" website it is working.

     

    protected void Btn_send_Click(object sender, EventArgs e)

    {

    WebClient client = new WebClient();

    client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

    client.QueryString.Add("user", "chandradev");

    client.QueryString.Add("password", "ALOSbn28");

    client.QueryString.Add("api_id", "3157247");

    //client.QueryString.Add("to", "919886003712");

    client.QueryString.Add("to", txtMobile.Text.ToString());

    client.QueryString.Add("text", txtText.Text.ToString());

    string baseurl = "http://api.clickatell.com/http/sendmsg";

    Stream data = client.OpenRead(baseurl);

    StreamReader reader = new StreamReader(data);string s = reader.ReadToEnd();

    data.Close();

    reader.Close();

    lbl_Msg.Text =
    "Message has been send sucessfully";

    txtMobile.Text = "";

    txtText.Text = "";

     

     

    }

     

    Monday, May 11, 2009 7:09 AM
  • User689809150 posted

     I found details on their webpage in connection with asp.net. You will find source code, prerequisites, schematic picture of the system, etc. - here: http://www.ozekisms.com/index.php?owpn=230

    Unfortunately I do not know any free carriers in India. 

    Monday, May 11, 2009 7:18 AM
  • User-1174271348 posted

     Thanks for the replay . How to get that API_ID .

    Monday, May 11, 2009 8:42 AM
  • User-1174271348 posted

     HI  chandradev

      I am getting Authentication Failed error . I am not able to send sms ,..

    Monday, May 11, 2009 8:58 AM
  • User970350993 posted

    Hi friend

    Firstly you go to that site and register there.Then you will get userId, password and API_ID . Then you keep in the the source code. It will work.

    Tuesday, May 12, 2009 12:19 AM
  • User1423414771 posted

    thanks brother my email is

    myasirmemon@gmail.com

    kindly send me

    thanks

    Monday, July 20, 2009 5:35 AM
  • User1435192664 posted

     Hi

    is there any code which can help me sending SMS without GSM Modem . I have visited http://www.ozekisms.com/ but it requires GSM modem

     

    thks

     

    Monday, September 14, 2009 3:44 PM
  • User1002812493 posted

    Hi Chandra Dev,

             I want to create the SMS sending option in my application. so as you told i followed the steps. send me the bulk sms site to register in it.

    Friday, November 13, 2009 8:14 AM
  • User970350993 posted

    hi

    did u get free Test sms  for check your code ? You will get 10 free sms for test perpose. After that you have to purchase from that site. so many site are providing this service.

    Friday, November 13, 2009 9:03 AM
  • User1002812493 posted

    hi,

       In which website i want to register to send the SMS in order to get that API_ID.

    Friday, November 13, 2009 11:32 PM
  • User970350993 posted

    Hi

    check this website

    http://www.clickatell.com/index2.php



    Saturday, November 14, 2009 12:07 AM
  • User-180320890 posted

    are you give some other detailed about error

    Regard
    Anirudha Gupta
    http://anirudhagupta.blogspot.com

    Mark As answer if i truely helped you

    Saturday, November 14, 2009 9:35 PM
  • User-1343063301 posted

    can you explain about to send sms from pc to mobile.. with coding of asp.net.. full coding i need


    Monday, November 23, 2009 6:00 AM
  • User297042814 posted

    use this Website To Send SMS All Over India

    http://www.spiritssoft.com/smswidget.htm

    http://www.spiritssoft.com/smswidget.aspx

    Add this code to html using IFrame:

     <iframe src="http://www.spiritssoft.com/smswidget.htm" width="468px" scrolling="no"   border="0" frameborder="0" name="I1"></iframe>


    From : Spirits Soft Technology
    www.spiritssoft.com



    Wednesday, December 2, 2009 6:57 AM
  • User40629646 posted

     





    Friday, December 4, 2009 5:32 PM
  • User628319771 posted

    Not working..


    Monday, December 28, 2009 5:27 AM
  • User628319771 posted

    server not found

    Monday, December 28, 2009 5:28 AM
  • User1199463438 posted


    Hi

    check this website

    http://www.clickatell.com/index2.php




    Hi Chandradev,

    I've register for clickatell API though not yet pay for the sms credit.


    Please, I will like to know if the sms can be automated based on my database and not necessarily clicking on send button.

    Any assistance in the codes to use will be higly appreciated.


    Thanks 

    Friday, January 15, 2010 5:34 AM
  • User970350993 posted

    Hi

    In that site, You will get Developer Api code . There will be one link to connect their server. After clicking on send button,

    that will varify userId and password. Then it will send sms from their server.


    Friday, January 15, 2010 9:42 AM
  • User-1423587422 posted

    Hi Friend,


    I need Send SMS from asp.net application.. PLs Guide me.. if u have the code pls mail me: My Id is mohanrao.divvela@gmail.com



    Tuesday, February 2, 2010 7:53 AM
  • User1199463438 posted

    Hi Friend,


    I need Send SMS from asp.net application.. PLs Guide me.. if u have the code pls mail me: My Id is mohanrao.divvela@gmail.com



    You may have a look at the following links, you will also need to register for gateway so that your message can be routed through the gateway to your recipient.

    http://www.clickatell.com/developers/clickatell_api.php

    http://www.clickatell.com/products/sms_gateway.php

    You will be required to register and buy credit, the site has VB.net script that u can use to integrate your ASP.Net to their gateway. there are options like HTTP, SMTP, COM, SOAP that yu can use to connect to their gateway.


    here is a sample VB.Net from the site and it works fine.

    Imports System.Net
    Imports System.IO
    Dim client As WebClient = New WebClient
    ' Add a user agent header in case the requested URI contains a query.
    client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR
    1.0.3705;)")
    client.QueryString.Add("user", "xxxx")
    client.QueryString.Add("password", "xxxx")
    client.QueryString.Add("api_id", "xxxx")
    client.QueryString.Add("to", "xxxx")
    client.QueryString.Add("text", "This is an example message")
    Dim baseurl As String = "http://api.clickatell.com/http/sendmsg"
    Dim data As Stream = client.OpenRead(baseurl)
    Dim reader As StreamReader = New StreamReader(data)
    Dim s As String = reader.ReadToEnd()
    data.Close()
    reader.Close()
    Return




    Hope it assist you

    Tuesday, February 2, 2010 11:45 AM
  • User937138743 posted

    pls check out this...

    http://www.codeproject.com/KB/aspnet/SendingSMS.aspx


    Monday, May 3, 2010 7:26 AM
  • User1199463438 posted


    Thanks for your response

    Tuesday, May 4, 2010 3:59 AM
  • User-820003471 posted

    Hello Chandradev,

    I am Kaushik Basu, S/W developer.

    I have to implement  to send sms from asp.net  application to mobile  in my project urgently, can you please send me the code.

    i am trying it from last few days but not succed yet..

    thank you in advance.

    Waiting for your reply

    Monday, May 17, 2010 7:21 AM
  • User-820003471 posted

    Hello Chandradev,

    I am Kaushik Basu, S/W developer.

    I have to implement  to send sms from asp.net  application to mobile  in my project urgently, can you please send me the code.

    i am trying it from last few days but not succed yet..

    lz send me in my Gmail Id   kaushikbasu2005@gmail.com

    thank you in advance.

    Waiting for your reply

    Monday, May 17, 2010 7:22 AM
  • User1199463438 posted

    You may have a look at the following links, you will also need to register for gateway so that your message can be routed through the gateway to your recipient.

    http://www.clickatell.com/developers/clickatell_api.php

    http://www.clickatell.com/products/sms_gateway.php

    You will be required to register and buy credit, the site has VB.net script that u can use to integrate your ASP.Net to their gateway. there are options like HTTP, SMTP, COM, SOAP that yu can use to connect to their gateway.

     

    here is a sample VB.Net from the site and it works fine.

    Imports System.Net
    Imports System.IO
    Dim client As WebClient = New WebClient
    ' Add a user agent header in case the requested URI contains a query.
    client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR
    1.0.3705;)")
    client.QueryString.Add("user", "xxxx")
    client.QueryString.Add("password", "xxxx")
    client.QueryString.Add("api_id", "xxxx")
    client.QueryString.Add("to", "xxxx")
    client.QueryString.Add("text", "This is an example message")
    Dim baseurl As String = "http://api.clickatell.com/http/sendmsg"
    Dim data As Stream = client.OpenRead(baseurl)
    Dim reader As StreamReader = New StreamReader(data)
    Dim s As String = reader.ReadToEnd()
    data.Close()
    reader.Close()
    Return

     

     

     

    Hope it assist you

    Monday, May 17, 2010 8:04 AM
  • User-262479890 posted

    http://www.2-waysms.com also they have the API for sending texts via HTTP with low rates.

    Wednesday, July 28, 2010 5:28 PM
  • User1553540217 posted

    Hi friend

    in which how what web service can use please send that Url

     

     

    Thank You 

    Thursday, July 29, 2010 12:25 AM
  • User1553540217 posted

    Hi

     

              please send me full code and web service Url please i need urgently for my project 

    Thursday, July 29, 2010 12:38 AM
  • User-1084878076 posted

    hi

    iam doing MCA its a final year . i am doing project in dotnet windows application in that i include sms. i dont know how to send sms through windows application plz help me how to send sms . and give me code . i want urgent plz help me most urgent ... my email id is hemu12.latha@gmail.com plz send code and give me idea how to send sms through application  

    Thursday, July 29, 2010 2:15 PM
  • User1199463438 posted

    hi

    iam doing MCA its a final year . i am doing project in dotnet windows application in that i include sms. i dont know how to send sms through windows application plz help me how to send sms . and give me code . i want urgent plz help me most urgent ... my email id is hemu12.latha@gmail.com plz send code and give me idea how to send sms through application  


    You'll need to use API, u may get this from clickatell.com. You can register for Clickatell Central API. there are lots of instruction to read on their website.

    They provide you series of codes in either VB.Net, C#, javascript

    U may read through this thread to see the codes I posted earlier.


    All da best

    Friday, July 30, 2010 9:59 AM
  • User-1084878076 posted

    clickatell.com this web site not working . plz give another solution.. 

    Friday, July 30, 2010 10:26 AM
  • User-1084878076 posted

    hi

    iam doing MCA its a final year . i am doing project in dotnet windows application in that i include sms. i dont know how to send sms through windows application plz help me how to send sms . and give me code . i want urgent plz help me most urgent ... my email id is hemu12.latha@gmail.com plz send code and give me idea how to send sms through application  

    Friday, July 30, 2010 10:28 AM
  • User401556289 posted

    Dear sir,

        I cannot understand how to send sms from Asp.net application with vb coding to any mobile.so sir pls help me.

    Friday, August 6, 2010 4:02 AM
  • User1508394307 posted

    Many cell companies can send SMS via email, so basically if your cell company has such service, you'll need to send an email message to a special mobile inbox. 

    Read this and this for more information.

    Hope this helps.

    Friday, August 6, 2010 4:22 AM
  • User1972703380 posted

    May i know did u include any library in your source code?

    Wednesday, September 15, 2010 1:17 PM
  • User1972703380 posted

    hi chandradev1,

    May i know did u include any library in your source code?

    Any declaration needed?


    thank you. 

    Wednesday, September 15, 2010 1:19 PM
  • User1199463438 posted

    May i know did u include any library in your source code?


    Yeah, U'll need to include this 2 libraries in your source code

    Imports System.Net
    Imports System.IO

    Imports System.Net

    Imports System.IO


    You may refers to my previous post on this thread for a sample code with the libraries include. Hope it is helpful



    Thursday, September 16, 2010 6:40 AM
  • User1972703380 posted

    Thank you for your reply. but do you mind posting up the sample code again.

    I cannot find it in the thread.

    Thank you so much.  

    Thursday, September 16, 2010 6:57 AM
  • User1199463438 posted

    Thank you for your reply. but do you mind posting up the sample code again.

    I cannot find it in the thread.

    Thank you so much.  


    You may have a look at the following links,but you will also need to register for gateway so that your message can be routed through the gateway to your recipient.

    I used clickatell for mine but there are many gateway providers out there, the choice is urs.

    http://www.clickatell.com/developers/clickatell_api.php

    http://www.clickatell.com/products/sms_gateway.php

    You will be required to register and buy credit, the site has VB.net script that u can use to integrate your ASP.Net to their gateway. there are options like HTTP, SMTP, COM, SOAP that yu can use to connect to their gateway.

     

    here is a sample VB.Net from the site and it works fine.

    Imports System.Net
    Imports System.IO
    Dim client As WebClient = New WebClient
    ' Add a user agent header in case the requested URI contains a query.
    client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR
    1.0.3705;)")
    client.QueryString.Add("user", "xxxx")
    client.QueryString.Add("password", "xxxx")
    client.QueryString.Add("api_id", "xxxx")
    client.QueryString.Add("to", "xxxx")
    client.QueryString.Add("text", "This is an example message")
    Dim baseurl As String = "http://api.clickatell.com/http/sendmsg"
    Dim data As Stream = client.OpenRead(baseurl)
    Dim reader As StreamReader = New StreamReader(data)
    Dim s As String = reader.ReadToEnd()
    data.Close()
    reader.Close()
    Return

     

     NOTE: on user, replace xxxx with ur username and do same for the remaining parameters as indicated.

     

    Hope it helps

     

     

    Thursday, September 16, 2010 8:03 AM
  • User1560559919 posted

    Thnks ....chandradev .....Smile

    Tuesday, October 26, 2010 8:35 AM
  • User-1676326381 posted

    hi chandra dev 

    plz send me the code on my mail id

    thanks.

    Tuesday, December 7, 2010 8:11 AM
  • User970350993 posted

    Hi

    I have already posted the code in forum. Plz read carefully and implement in your  project. I hope you can do easily. 

    Wednesday, December 8, 2010 2:05 AM
  • User-384516251 posted

    thanks Bro!

    Wednesday, December 8, 2010 12:07 PM
  • User-1676326381 posted

    thanx Laughing 

    Friday, December 10, 2010 3:06 AM
  • User1754649086 posted

    Hi Chandra dev,

    Can you please send me the code to send SMS from .NET application. My Email address is ntalakola@gmail.com

     

    Thanks

    Narayana Reddy 

    Wednesday, January 19, 2011 9:08 PM
  • User1732097990 posted

    Hi ChandraDev,
     
    I am varakumar, understand from one of your earlie thread, that you were exploring on the "auto send - SMS" using clickatell SMS gateway.
     
    I was trying a program (vb.net) from past week using the same approach but could not successed yet, getting an error "The remote server returned an error: (407) ProxyAuthentication Required..." hope you have already done. Can you help me also, by providing your code with you valuable advice.
     
    Below is the error which i am getting when i tried. 
     Error:
    ------
    System.Net.WebException: The remote server returned an error: (407) ProxyAuthentication Required.
      at System.Net.WebClient.OpenRead(Uri address)
      at System.Net.WebClient.OpenRead(String address)
      at WAppl_sendSMS.SMS.btn_sendSMS_Click(Object sender, EventArgs e) at line 37 

    Code:
    -----  
     Dim client As WebClient = New WebClient
     client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")

     client.QueryString.Add("user", "xxxx")      '' xxxx replaced with correct userid only
     client.QueryString.Add("password", "xxxxx") '' xxxx replaced with correct password only
     client.QueryString.Add("api_id", "3288213")
     client.QueryString.Add("to", "6590671931")
     client.QueryString.Add("text", "First Testing Joe")

    line 36: Dim baseurl As String = "http://api.clickatell.com/http/sendmsg"
    line 37: Dim data As Stream = client.OpenRead(baseurl)

      Dim reader As StreamReader = New StreamReader(data)
      Dim s As String = reader.ReadToEnd()

      data.Close()
      reader.Close()
      client = Nothing
      Return

    --------------------<end of code> ------------------------------------- 

    Any one can help me... please.. please

    Many thanks in advance.
     
    Best Regards,
    vara kumar

    gvarakumar@gmail.com

    Thursday, March 3, 2011 4:06 AM
  • User1383228988 posted
    thank you so much , It was really helpful
    Friday, March 4, 2011 12:24 PM
  • User1732097990 posted

    Hi chandradev,

    Any updates, where iam doing wrong, please correct me or advice.

    Thank you

    varakumar

    Thursday, March 10, 2011 7:11 AM
  • User313344865 posted

    hey i also want to learn how to send sms using .NEt application

     

    please help me out

    my emai id is :- darshandoshi_272@yahoo.com

    Sunday, March 13, 2011 10:48 PM
  • User1553540217 posted

      //SqlConnection nwindConn = new SqlConnection("Data Source=INTEL-PC;Initial Catalog=Test;User ID=sa;Password=redhat");
            //SqlDataAdapter catDA = new SqlDataAdapter("uspSlect", nwindConn);
            //catDA.InsertCommand = new SqlCommand("uspSlect", nwindConn);        //catDA.InsertCommand.CommandType = CommandType.StoredProcedure;
            //SqlParameter myParm = catDA.InsertCommand.Parameters.Add("@RowCount", SqlDbType.Int);        //myParm.Direction = ParameterDirection.ReturnValue;
            //catDA.InsertCommand.Parameters.Add("@CategoryName", SqlDbType.VarChar, 15, txtName.Text);
            //myParm = catDA.InsertCommand.Parameters.Add("@Identity", SqlDbType.Int, 0, "0");        //myParm.Direction = ParameterDirection.Output;
            //DataSet catDS = new DataSet();        //catDA.Fill(catDS, "uspSlect");
            //DataRow newRow = catDS.Tables["uspSlect"].NewRow();        //newRow["CategoryName"] = "New Category";        //catDS.Tables["Categories"].Rows.Add(newRow);
            //catDA.Update(catDS, "Categories");
            //Int32 rowCount = (Int32)catDA.InsertCommand.Parameters["@RowCount"].Value;



            SqlCommand cmd = new SqlCommand("uspSlect", con);        cmd.CommandType = CommandType.StoredProcedure;       // SqlParameter parm = new SqlParameter("@CategoryName", SqlDbType.VarChar );       // parm.Value = "ALFKI";       //// parm.Direction = ParameterDirection.Input;       // cmd.Parameters.Add(parm);       // //SqlParameter parm2 = new SqlParameter("@Identity", SqlDbType.VarChar);       // //parm2.Size = 50;       // //parm2.Direction = ParameterDirection.Output;       // //cmd.Parameters.Add(parm2);       // SqlParameter parm3 = new SqlParameter("@Identity", SqlDbType.Int);       // parm3.Direction = ParameterDirection.Output;       // cmd.Parameters.Add(parm3);
            SqlCommand cmd = new SqlCommand("uspSlect", con);        cmd.CommandType = CommandType.StoredProcedure;        pa = new SqlParameter[2];        (pa[0] = new SqlParameter("@Identity", SqlDbType.Int)).Value = Convert.ToInt32(0);        pa[0].Direction = ParameterDirection.Output;        (pa[1] = new SqlParameter("@CategoryName", SqlDbType.VarChar, 10)).Value = txtName.Text;
            for (int i = 0; i < pa.Length; i++)        {            cmd.Parameters.Add(pa[i]);        }        //cmd.Parameters.AddWithValue("@CategoryName", "dfdf");        //cmd.Parameters.AddWithValue("@Identity", 0);        //ParameterDirection.Output;        con.Open();        cmd.ExecuteNonQuery();        con.Close();
            int a=(int) (cmd.Parameters["@Identity"].Value);        Response.Write(cmd.Parameters["@Identity"].Value.ToString());       // Response.ReadLine(); 

     

     

     

    alter PROCEDURE uspSlect  @CategoryName varchar(15)=null,  @Identity int=null OUT ASINSERT INTO identy (nam) VALUES(@CategoryName)SET @Identity = @@Identity--RETURN @@ROWCOUNT

    Tuesday, April 5, 2011 10:17 PM
  • User1553540217 posted

      //SqlConnection nwindConn = new SqlConnection("Data Source=INTEL-PC;Initial Catalog=Test;User ID=sa;Password=redhat");
            //SqlDataAdapter catDA = new SqlDataAdapter("uspSlect", nwindConn);
            //catDA.InsertCommand = new SqlCommand("uspSlect", nwindConn);        //catDA.InsertCommand.CommandType = CommandType.StoredProcedure;
            //SqlParameter myParm = catDA.InsertCommand.Parameters.Add("@RowCount", SqlDbType.Int);        //myParm.Direction = ParameterDirection.ReturnValue;
            //catDA.InsertCommand.Parameters.Add("@CategoryName", SqlDbType.VarChar, 15, txtName.Text);
            //myParm = catDA.InsertCommand.Parameters.Add("@Identity", SqlDbType.Int, 0, "0");        //myParm.Direction = ParameterDirection.Output;
            //DataSet catDS = new DataSet();        //catDA.Fill(catDS, "uspSlect");
            //DataRow newRow = catDS.Tables["uspSlect"].NewRow();        //newRow["CategoryName"] = "New Category";        //catDS.Tables["Categories"].Rows.Add(newRow);
            //catDA.Update(catDS, "Categories");
            //Int32 rowCount = (Int32)catDA.InsertCommand.Parameters["@RowCount"].Value;



            SqlCommand cmd = new SqlCommand("uspSlect", con);        cmd.CommandType = CommandType.StoredProcedure;       // SqlParameter parm = new SqlParameter("@CategoryName", SqlDbType.VarChar );       // parm.Value = "ALFKI";       //// parm.Direction = ParameterDirection.Input;       // cmd.Parameters.Add(parm);       // //SqlParameter parm2 = new SqlParameter("@Identity", SqlDbType.VarChar);       // //parm2.Size = 50;       // //parm2.Direction = ParameterDirection.Output;       // //cmd.Parameters.Add(parm2);       // SqlParameter parm3 = new SqlParameter("@Identity", SqlDbType.Int);       // parm3.Direction = ParameterDirection.Output;       // cmd.Parameters.Add(parm3);
            SqlCommand cmd = new SqlCommand("uspSlect", con);        cmd.CommandType = CommandType.StoredProcedure;        pa = new SqlParameter[2];        (pa[0] = new SqlParameter("@Identity", SqlDbType.Int)).Value = Convert.ToInt32(0);        pa[0].Direction = ParameterDirection.Output;        (pa[1] = new SqlParameter("@CategoryName", SqlDbType.VarChar, 10)).Value = txtName.Text;
            for (int i = 0; i < pa.Length; i++)        {            cmd.Parameters.Add(pa[i]);        }        //cmd.Parameters.AddWithValue("@CategoryName", "dfdf");        //cmd.Parameters.AddWithValue("@Identity", 0);        //ParameterDirection.Output;        con.Open();        cmd.ExecuteNonQuery();        con.Close();
            int a=(int) (cmd.Parameters["@Identity"].Value);        Response.Write(cmd.Parameters["@Identity"].Value.ToString());       // Response.ReadLine(); 

     

     

     

    alter PROCEDURE uspSlect  @CategoryName varchar(15)=null,  @Identity int=null OUT ASINSERT INTO identy (nam) VALUES(@CategoryName)SET @Identity = @@Identity--RETURN @@ROWCOUNT

    Tuesday, April 5, 2011 10:17 PM
  • User-1947958263 posted
    protected void btnmailsend_Click(object sender, EventArgs e)
    {
    MailMessage objmm = new MailMessage();
    objmm.To = "xxx@xxx.com";
    objmm.From = "yyy@yyy.com";
    objmm.BodyFormat = MailFormat.Text;
    objmm.Subject = "This is the subject";
    objmm.Body = "This is the body";
    SmtpMail.SmtpServer = "localhost";//uses the iis default smtp host
    SmtpMail.Send(objmm);
    }


    for reference visit
    http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true
    http://devlicio.us/blogs/mike_nichols/archive/2008/05/07/configuring-iis-6-0-to-send-mail-via-smtp-for-asp-net-applications.aspx


    Monday, November 21, 2011 7:25 AM
  • User-1947958263 posted

    but the mobile verification code is not reaching yet..

    Monday, November 21, 2011 7:33 AM
  • User-1573346080 posted

    Can you send me the exact code and how to do it. Thanks  a lot.

    gsting2@gmail.com

    Sunday, November 27, 2011 2:27 PM