我想发短信给手机号码印度。我正在使用此代码。
MailMessage message= new MailMessage("FROM SENDER", "9456734352@messaging.sprintpcs.com", "Message Subject", "My Message Data");
SmtpClient mySmtpClient=new SmtpClient("mail.xyz.com");
mySmtpClient.UseDefaultCredentials = True;
mySmtpClient.Send(message);
MessageBox.Show("Message sent successfully");
我收到错误消息
The specified string is not in the form required for an e-mail address.
由于我是新手,所以我对此并不太了解!我能做些什么来完成这项工作?
编辑:
错误
Failure sending mail
答案 0 :(得分:2)
您可以使用AT命令和个人手机发送所需数量的短信。只需通过USB线连接到PC,即可为手机分配COM端口
private void button1_Click(object sender, EventArgs e)
{
this.serialPort = new SerialPort();
this.serialPort.PortName = "COM5";
this.serialPort.BaudRate = 9600;
this.serialPort.Parity = Parity.None;
this.serialPort.DataBits = 8;
this.serialPort.StopBits = StopBits.One;
this.serialPort.Handshake = Handshake.RequestToSend;
this.serialPort.DtrEnable = true;
this.serialPort.RtsEnable = true;
this.serialPort.NewLine = System.Environment.NewLine;
serialPort.Open();
send_sms();
}
public bool send_sms()
{
String SMSMessage = "gsm MESSAGE FROM .NET C#";
String CellNumber = "+913333333333";
if (serialPort.IsOpen)
{
this.serialPort.WriteLine(@"AT" + (char)(13));
Thread.Sleep(200);
this.serialPort.WriteLine("AT+CMGF=1" + (char)(13));
Thread.Sleep(200);
this.serialPort.WriteLine(@"AT+CMGS=""" + CellNumber + @"""" + (char)(13));
Thread.Sleep(200);
this.serialPort.WriteLine(SMSMessage + (char)(26));
return true;
}
serialPort.Close();
return false;
}