send sms using c# code

The following code sample shows how to sent sms using c# code


class MyClass
{
public mCore.SMS objSMS = new mCore.SMS();

public MyClass()

{
objSMS.NewDeliveryReport +=
new mCore.SMS.DeliveryReportHandler(objSMS_NewDeliveryReport);
}

public static void SendMessage()
{
string strResult = "";
string strMsg = "This is a test message"
try
{

SetCommParameters();
objSMS.Encoding = mCore.Encoding.GSM_Default_7Bit;
objSMS.LongMessage = mCore.LongMessage.Concatenate;
objSMS.DeliveryReport = true;
try
{
strResult = objSMS.SendSMS("+919873094767", strMsg);
MessageBox.Show(strResult);
}
catch (mCore.SMSSendException e)
{
MessageBox.Show("Message Failed!" + "\r\n" + e.ToString());
}
}

catch (mCore.GeneralException e)
{
MessageBox.Show(e.ToString());
}
catch (Exception e)
{
}
}

private void objSMS_NewDeliveryReport
(object sender, mCore.DeliveryReportEventArgs e)
{
if (e.Status)
{
MessageBox.Show("MESSAGE DELIVERED" + "\r\n\r\n" +
"TO: " + e.Phone + "\r\n\r\n" +
"DELIVERY DATE/TIME: " + e.DeliveryTimeStamp.ToString() +
"\r\n\r\n" + "[Message Ref.: " +
e.MessageReference.ToString() + "]");
}
else
{
MessageBox.Show("MESSAGE DELIVERY FAILED" + "\r\n\r\n" +
"TO: " + e.Phone + "\r\n\r\n" +
"REPORT DATE/TIME: " + e.DeliveryTimeStamp.ToString() +
"\r\n\r\n" + "[Message Ref.: " +
e.MessageReference.ToString() + "]");
}
}

public static void SetCommParameters()
{
try
{
objSMS.Port = "COM1";
objSMS.BaudRate = mCore.BaudRate.BaudRate_19200;
objSMS.DataBits = mCore.DataBits.Eight;
objSMS.StopBits = mCore.StopBits.One;
objSMS.Parity = mCore.Parity.None;
objSMS.FlowControl = mCore.FlowControl.RTS_CTS;
}

catch (mCore.GeneralException e)
{
MessageBox.Show(e.ToString());
}
catch (Exception e)
{
}
}
}


Comments

Author: Nirav M. Mehta01 May 2008 Member Level: Gold   Points : 2

Plz provide whole code with page code also

Author: Sagar Deshpande07 May 2008 Member Level: Bronze   Points : 2

Its a nice snippet

Author: Kamal07 May 2008 Member Level: Gold   Points : 2

hi,

please give full description how this work?

And also it support all network.

Author: Nithya07 May 2008 Member Level: Bronze   Points : 2

pls Descripe about mCore..What is this?
please provide me mCore....

Author: kanagarajum07 May 2008 Member Level: Gold   Points : 2

Hai
Please give full description

Author: venkat kamal07 May 2008 Member Level: Gold   Points : 2

Hi,its nice to see about this article and will u plz provide full description as well as coding...........

Author: vairamuthu08 May 2008 Member Level: Silver   Points : 2

please provide full description

Author: mani08 May 2008 Member Level: Silver   Points : 2

description and comments in detail please

Author: Jai14 May 2008 Member Level: Gold   Points : 2

hi,
nice example.
but, are you used sms service this code?

if u used the sms service free or cost?

Author: mani kumar.k.m14 May 2008 Member Level: Gold   Points : 2

hi,
nice example.
its working good. how to use the sms service this code?

if u used the sms service free or cost?

send to me the detail in my mail id - kmmkumar@gmail.com

thanks.

Author: Vasudevan Deepak Kumar14 May 2008 Member Level: Gold   Points : 2

@Nithya,

A quick search for MCore got me this component: http://www.logixmobile.com/products/mcore/index.asp

Perhaps the author can confirm whether this is the component that she is trying to use for the purpose of sending text messages.

Author: R O B I N21 May 2008 Member Level: Gold   Points : 2

I m facing the problem of sending the message
i m getting the error message
.......ERROR 2016: Unknown error while checking PIN status....
can you suggest any solution for it.

Author: Praveena kandhi26 May 2008 Member Level: Gold   Points : 2

plz explain in detail

Author: vijetha29 May 2008 Member Level: Gold   Points : 2

Nice code

Author: deebpratap29 May 2008 Member Level: Bronze   Points : 2

Hi, concept is great .plz provide abt this in detail..

Author: Chandra Sheker.G29 May 2008 Member Level: Gold   Points : 2

Hi,good code but pls can u sned me full code

Author: Deepak S18 Aug 2008 Member Level: Gold   Points : 0

hai,
Plz send the full code.

Thanks & Regards,

Deepak S

Author: surender07 Sep 2008 Member Level: Silver   Points : 0

Hello Nice T Share ur Knowledge bt can u send me the full code?

Author: Yogini01 Dec 2008 Member Level: Bronze   Points : 1

I want to develop an application in Asp.net 3.5 with c# for sending bulk sms in India. So plz tell me how to do without using modem. if i want to use Sms service provider then tell how to use that in .net & implement. plz provide me all details of implementation fron scratch.

Thanks in advance.

Author: Yogini01 Dec 2008 Member Level: Bronze   Points : 1

I want to develop an application in Asp.net 3.5 & c# for sending bulk sms in India. So plz tell me how to do without using modem. if i want to use Sms service provider then tell how to use that in .net & implement. plz provide me all details of implementation fron scratch.

Thanks in advance.

Author: krishna05 Dec 2008 Member Level: Gold   Points : 0

Hi,good code but pls can u sned me full code

Regards,
Krishna.

Author: KR12 Dec 2008 Member Level: Gold   Points : 0

Hi,
Good code.

Author: Sayre08 May 2009 Member Level: Gold   Points : 0

Hi, Incomplete Code

Author: satya08 May 2009 Member Level: Bronze   Points : 0

GOOD

Author: Selvakumar01 Jul 2009 Member Level: Bronze   Points : 1

Hi all,
pls anybody can give me a sending SMS code(without using modam) ,service provider and gateway details...?

Thanks in Advance

Author: Gaurav Aroraa02 Jul 2009 Member Level: Gold   Points : 2

Asha,

Definitely your work is remarkable. But your code does not give any output until you provide following:

1. What are the SMS services your using
2. SMS-Providers for the services
3. Is there any cost involved to use this service or its free

Look simply use a service and just paste the code here is not showing full work.

I have drop you a separate message if you have full service please upload here so others can be benefited from the same.

Author: L Sagar07 Sep 2009 Member Level: Gold   Points : 0

Hi,
super code ...Thanks

Regards
sagar

Author: muthuraman07 Sep 2009 Member Level: Gold   Points : 1

hi mehta,
nice try.
plz give full details, so that it will help us.
thanks,

muthuraman

Author: satya13 Sep 2009 Member Level: Gold   Points : 1

Hi,
Please provide the full code.

Then it will be useful for all.

Thanks & Regards,
Satya

Author: Pavneet19 Sep 2009 Member Level: Gold   Points : 0

Please Give Full Descrip

Author: Aravind15 Oct 2009 Member Level: Bronze   Points : 1

Thnx
Can u Send me Send full Page code to mail plsss
my mail id is aravindvenkat18@gmail.com

Author: Saroj Kumar Raut28 Apr 2010 Member Level: Silver   Points : 0

can you send me the full code . i m in badly need for that.

Author: Nishikant29 Apr 2010 Member Level: Gold   Points : 1

Hi,

Can you please provide the whole code?

If possible, explain the code and also attach the code in zip or rar format.

Author: Manju30 Apr 2010 Member Level: Gold   Points : 1

Hi,

It would be more useful if detailed code and comments are provided.

Regards,
Manju

Author: deepak laxmanrao14 Jul 2010 Member Level: Bronze   Points : 0

can u send me the full code?
mdyusri696@gmail.com
thanks.....

Author: Shivshanker Cheral30 Aug 2010 Member Level: Gold   Points : 2

Check http://www.nowsms.com or http://www.kannel.org
These are 2 SMS gateways the first one is commercial and runs under windows
the second is free and open source and runs under linux. You can communicate
with both using HTTP from your c# application. I use kannel (that runs on
linux) with my C# application (that runs on windows) and it is working fine
sending a large number of messages everyday.

Guest Author: Diksha01 Nov 2012

what is mCore used for ,is it that we need to add some namespaces



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: