如何使用SMTP服务器的Windows应用程序发送短信到移动? [英] How to send SMS to mobile using SMTP server in windows application?

查看:383
本文介绍了如何使用SMTP服务器的Windows应用程序发送短信到移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

结果我开发使用C#一个Windows应用程序,其中我想发送短信到基于某些条件的一些用户。我穿过很多论坛上的帖子,但他们没有用满了我使用SMTP服务器发送短信。在这个 我得到了一些线索,通过Gmail SMTP,但工作不发送短信,因为我认为这是运营商特定的(不知道)。结果
我的代码示例:搜索


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("1568235685@sms.sancharnet.in");
    message.From = new MailAddress("sameone@gmail.com"); //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("someonet@gmail.com", "password");

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



上面的代码不给任何异常或错误,而且我没有得到任何SMS在我的序号。
结果

那么,我要问,什么是有任何方式使用SMTP服务器向任何运营商的手机号码发送短信?

推荐答案

您要发送到短信网关。它是特定的提供者。

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

维基百科有一个列表。

例如,以发送到Sprint PCS的号码,你会发送到number@messaging.sprintpcs.com,其中号码是电话号码(即5551234567,或等等)。

For example, to send to a Sprint PCS number you would send to number@messaging.sprintpcs.com, where number is the phone number (i.e. 5551234567, or whatever).

这篇关于如何使用SMTP服务器的Windows应用程序发送短信到移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆