var message = new MailMessage();
message.From = new MailAddress("sender@foo.bar.com");
message.To.Add(new MailAddress("5551234567@txt.att.net"));//See carrier destinations below
//message.To.Add(new MailAddress("5551234568@txt.att.net"));
//message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));
message.Subject = "This is my subject";
message.Body = "This is the content";
var client = new SmtpClient();
client.Send(message);
using System;
using Twilio;
class Example
{
static void Main(string[] args)
{
// Find your Account Sid and Auth Token at twilio.com/user/account
string AccountSid = "{{ account_sid }}";
string AuthToken = "{{ auth_token }}";
var twilio = new TwilioRestClient(AccountSid, AuthToken);
var message = twilio.SendMessage("+14158141829", "+14159352345", "This text message was sent with code!");
Console.WriteLine(message.Sid);
}
}
public partial class Form1 : Form
{
SMSCOMMS SMSEngine;
public Form1()
{
SMSEngine = new SMSCOMMS("COM1");
InitializeComponent();
SMSEngine.Open();
}
private void button1_Click(object sender, EventArgs e)
{
SMSEngine.SendSMS("919888888888","THIS IS YOUR MESSAGE");
SMSEngine.Close();
}
}
}
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json; // Install-Package Newtonsoft.Json
class Program
{
static async Task Main(string[] args)
{
// Set the URL to send the POST request to
string url = "https://api.d7networks.com/messages/v1/send";
// Create a new HttpClient object
HttpClient client = new HttpClient();
// Set the bearer token authentication header
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "YOUR_API_TOKE"); // Replace YOUR_API_TOKEN with your API token
// Create a new message object with channel, recipients, and content attributes
var message = new
{
originator = "smsinfo", // Replace smsinfo with your sender ID
recipients = new string[] { "+97150900XXXX"}, // Replace +97150900XXXX with your recipient's number
content = "Testing multi lined message. \n This is the second line. \n This is the third line."
};
// Nest the message object inside a messages object
var messages = new
{
messages = new[] { message }
};
// Convert the messages object to a JSON string
string json = JsonConvert.SerializeObject(messages);
// Create a new StringContent object with the JSON string
var content = new StringContent(json, Encoding.UTF8, "application/json");
// Send the POST request and get the response
HttpResponseMessage response = await client.PostAsync(url, content);
// Print the response status code and message
Console.WriteLine($"Response status code: {response.StatusCode}");
Console.WriteLine($"Response message: {await response.Content.ReadAsStringAsync()}");
}
}
5条答案
按热度按时间ht4b089n1#
大多数主要运营商都提供电子邮件到文本服务。该程序可以使用电子邮件发送SMS消息。例如:
发送邮件
运营商目的地
替代品
5cnsuln72#
Twilio有一个C# helper library可以让你做到这一点。
以下是使用库发送文本消息所需的代码:
免责声明:我为Twilio工作。
rjee0c153#
您可以通过各种方式发送短信
您可以通过下面提供的链接了解上述每一点的基本逻辑,并尝试在代码中实现这一点。
http://www.codeproject.com/Articles/19023/Sending-SMS-using-NET
你需要像这样在表单构造函数中创建一个sms引擎的示例。
gmol16394#
Ozeki的C# sms api以事件的形式提供反馈。这很棒,因为其他短信api-s不提供传递到手机的报告或任何其他关于短信发生情况的真实的反馈。下面是代码。
使用系统;使用OZX;
命名空间OzekiConsoleClient { class Program { static OzxClient Client;
}
您还可以使用此代码通过Android移动的发送SMS,而不是订阅在线SMS服务。
免责声明:我为Ozeki工作。
dffbzjpn5#
我使用的是https://d7networks.com/,集成很简单