问题描述
我正在使用 C# 开发一个 Windows 应用程序,我想在其中根据某些条件向某些用户发送 SMS.我浏览了许多论坛帖子以使用 SMTP 服务器发送短信",但没有一个对我有用.在 this 我得到了一些通过 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("[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");
}
上面的代码没有给出任何异常或错误,但我的号码也没有收到任何短信.
那么,我想问的是,有没有办法使用 SMTP 服务器向任何运营商的手机号码发送短信?
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?
推荐答案
你必须发送到短信网关.它是特定于提供商的.
You have to send to the SMS gateway. It is provider specific.
维基百科有一个短信网关列表.
例如,要发送到 Sprint PCS 号码,您可以发送到 [email protected],其中 number 是电话号码(即 5551234567 或其他).
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).
这篇关于如何在 Windows 应用程序中使用 SMTP 服务器向手机发送短信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!