Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send SMS to mobile using SMTP server in windows application?


I am developing a windows application using C#, in which i want to send SMS to some user based on some condition. i goes through the many forum post to "Send SMS using SMTP Server" but none of them use-full for me. In this i got some clue to send SMS through Gmail SMTP but not working as i think it is carrier specific (not sure).
My code sample :

try
{
    MailMessage message = new MailMessage();
    message.To.Add("[email protected]");
    message.From = new MailAddress("[email protected]"); //See the note afterwards...
    message.Body = "Hi, How r you ?";

    SmtpClient smtp = new SmtpClient("smtp.gmail.com");
    smtp.EnableSsl = true;
    smtp.Port = 587;
    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtp.Credentials = new NetworkCredential("[email protected]", "password");

    smtp.Send(message);
    MessageBox.Show("Message sent successfully");
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message, "Error");
}

above code not giving any exception or error but also i am not getting any sms on my number as well.

So, what i want to ask that is there any way to send SMS using SMTP server to the mobile number of any carrier?

like image 513
BhushanK Avatar asked Oct 28 '13 13:10

BhushanK


1 Answers

You have to send to the SMS gateway. It is provider specific.

Wikipedia has a List of SMS Gateways.

For example, to send to a Sprint PCS number you would send to [email protected], where number is the phone number (i.e. 5551234567, or whatever).

like image 101
Jim Mischel Avatar answered Sep 23 '22 00:09

Jim Mischel