C# .NET - Code for sending Text message - Asked By Ajay Gupta on 17-Dec-08 09:48 AM

Hi, cn sm1 help me by telling me the code in vb, How to send a text message from computer to phone..

A free .NET based SMS library is available - Venkat K replied to Ajay Gupta on 17-Dec-08 09:52 AM

at: http://www.dotnetspider.com/resources/2548-Sending-SMS-from-C-application.aspx

you can refer the dll present in the above url and you can easily send the sms to the moble from c#. :)

Send Text Message to Cell Phones from a C# Application - Binny ch replied to Ajay Gupta on 17-Dec-08 09:58 AM

private void btnSend_Click(System.Object sender, System.EventArgs e)

   {

     // Collect user input from the form and stow content into

     // the objects member variables

        mTo = Trim(txtPhoneNumber.Text) & Trim(cboCarrier.SelectedItem.ToString());

        mFrom = Trim(txtSender.Text);

        mSubject = Trim(txtSubject.Text);

        mMailServer = Trim(txtMailServer.Text);

        mMsg = Trim(txtMessage.Text);

     // Within a try catch, format and send the message to

     // the recipient.  Catch and handle any errors.

         try

           {

            MailMessage message= new MailMessage(mFrom, mTo, mSubject, mMsg);

            SmtpClient mySmtpClient=new SmtpClient(mMailServer);

            mySmtpClient.UseDefaultCredentials = True;

            mySmtpClient.Send(message);

            MessageBox.Show("The mail message has been sent to " & message.To.ToString(), "Mail", MessageBoxButtons.OK, MessageBoxIcon.Information);

           }

         catch(FormatException ex)

           {

            MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);

           }

         catch(SmtpException ex)

           {

            MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);

           }

        catch(Exception ex)

           {

            MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);

           }

        }

Example code to send text messages written in C#. - Binny ch replied to Ajay Gupta on 17-Dec-08 10:02 AM

using System.Web.Mail;
.
.
.
string toPhoneNumber = "DestinationPhoneNumber";
string login = "YoureIPIPIUsername";
string password = "YourPassword";
string compression = "Compression Option goes here - http://www.ipipi.com/help/compression.htm";
string body = "Your Message";


System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
mail.To = toPhoneNumber + "@sms.ipipi.com";
mail.From = login + "@ipipi.com";
mail.Subject = compression;
mail.Body = body;
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", login);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);


System.Web.Mail.SmtpMail.SmtpServer = "ipipi.com";
System.Web.Mail.SmtpMail.Send( mail );


Also see this link:

http://www.c-sharpcorner.com/UploadFile/scottlysle/TextMsgToCellPhone12112006002339AM/TextMsgToCellPhone.aspx

It is as simple as sending an email to whatever the email address is for that carrier, list here

http://www.livejournal.com/tools/textmessage.bml?mode=details

TRY THIS CODE - C_A P replied to Ajay Gupta on 18-Dec-08 04:45 AM
1. As the System.Net.Mail namespace was decalred at the beginning of
the tutorial, we can pass to the sending code (for the Send button):

private void button1_Click(object sender, EventArgs e)
       
{
           
// To avoid situations, when the program crashes because server rejection or
           
// invalid data, an exception handling mechanism is created.
           
try
           
{
               
// Creating a new SMTP Client. The server URL/IP is indicated as
               
// sendServer.Text (that is the text box with the data).
               
SmtpClient client = new SmtpClient(sendServer.Text);

               
// Creating a new mail message. The sender and receiver are
               
// indicated as sendFrom.Text and SendTo.Text
               
// (these are the text boxes with the data).
               
MailMessage message = new MailMessage(sendFrom.Text, sendTo.Text);

               
// The message body is the message content provided in the
               
// contentBox.
                message
.Body = contentBox.Text;

               
// The message subject is located in the subjectBox.
                message
.Subject = subjectBox.Text;

               
// To be able to send the message, it is necessary to provide the
               
// credentials on the server. The username is located in the userBox
               
// and the password is located in the passBox.
                client
.Credentials = new System.Net.NetworkCredential(userBox.Text, passBox.Text);

               
// Some servers require a specific port to connect,
               
// so it is specified in the serverPort text box.
               
if (serverPort.Text != null)
                client
.Port = System.Convert.ToInt32(serverPort.Text);

               
// Send the message.
                client
.Send(message);
           
}

           
// This catches the exceptions, if any.
           
catch (Exception ex)
           
{
               
// Show a message, explaining the problem.
               
MessageBox.Show("Cannot send message: " + ex.Message);
           
}
       
}

2. There is also code for the 'Clear Fields' button:

csharp

// Clear every field.
            sendServer
.Clear();
            serverPort
.Clear();
            sendTo
.Clear();
            sendFrom
.Clear();
            userBox
.Clear();
            passBox
.Clear();
            subjectBox
.Clear();
            contentBox
.Clear();
SOURCE FROM : http://www.dreamincode.net/forums/showtopic57355.htm
TRY THIS LINK - C_A P replied to Ajay Gupta on 18-Dec-08 04:47 AM

http://www.codeproject.com/KB/database/SMS_message_from_SQL.aspx

http://www.dreamincode.net/forums/showtopic57355.htm

http://www.soulcast.com/post/show/52339/SENDING-SMS-USING-C%23-source-code

http://www.sourcecodeonline.com/details/send_an_sms_text_message.html

 

Hi - Ajay Gupta replied to Binny ch on 22-Dec-08 09:42 AM
Hi, This ipipi.com is not working i searched so many but all are paid i want a free one, I think i want a free account where i register my cell phone number so that i can send messages to otherss, m i rite??
regarding sending sms in c#.net - tech soft replied to Binny ch on 11-Jun-09 03:33 AM
hello,
i just want to know how to send sms frm windows application using c#.net to mobile?
can u tell the coding and procedure for that?
thanks,
arijit
regarding sending sms in c#.net - tech soft replied to Binny ch on 11-Jun-09 03:34 AM
hello,
i just want to know how to send sms frm windows application using c#.net to mobile?
can u tell the coding and procedure for that?
thanks,
arijit
Perumal replied to tech soft on 18-Oct-10 01:46 AM
i just want to know how to send sms frm windows application using c#.net to mobile?