How SMS Farsi (Arabic) with a GSM modem, I upload C #

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi .. I have a question with the following code to easily send SMS but can not do other languages ​​do send word. (eg "in Arabic). I read somewhere that I must first code word after I submitted.<br/>
<br/>
The following code Im easy to send messages.


<div style="color:black; background-color:white
<pre><span style="color:blue using System;
<span style="color:blue using System.Collections.Generic;
<span style="color:blue using System.ComponentModel;
<span style="color:blue using System.Data;
<span style="color:blue using System.Drawing;
<span style="color:blue using System.Text;
<span style="color:blue using System.Windows.Forms;
<span style="color:blue using System.IO.Ports;
<span style="color:blue using System.Threading;
<span style="color:blue namespace sms_at_command
{
<span style="color:blue public <span style="color:blue partial <span style="color:blue class Form1 : Form
{
SerialPort myport = <span style="color:blue new SerialPort();
<span style="color:blue string DeviceName = <span style="color:#a31515 "";
<span style="color:blue public Form1()
{
InitializeComponent();
<span style="color:green //تنظیمات پورت
myport.BaudRate = 9600;
myport.Parity = Parity.None;
myport.StopBits = StopBits.One;
myport.DataBits = 8;
myport.ReadBufferSize = 10000;
myport.ReadTimeout = 1000;
myport.WriteBufferSize = 10000;
myport.WriteTimeout = 10000;
myport.RtsEnable = <span style="color:blue true;
}
<span style="color:blue private <span style="color:blue void Form1_Load(<span style="color:blue object sender, EventArgs e)
{
cmbPortName.SelectedIndex = 0;
}
<span style="color:blue private <span style="color:blue void button1_Click(<span style="color:blue object sender, EventArgs e)
{
<span style="color:blue if (cmbPortName.Text.Trim() != <span style="color:#a31515 "")
{
<span style="color:blue try
{
lblDeviceName.Text = <span style="color:#a31515 "";
myport.PortName = cmbPortName.Text.Trim();
<span style="color:blue if (!myport.IsOpen)
myport.Open();
myport.DiscardOutBuffer();<span style="color:green //خالی کردن بافر
myport.WriteLine(<span style="color:#a31515 "AT+cgmmr");<span style="color:green //دستور شناخت مدل دستگاه
Thread.Sleep(500);
DeviceName = myport.ReadExisting();
<span style="color:blue if (DeviceName.Contains(<span style="color:#a31515 "ERROR"))
MessageBox.Show(<span style="color:#a31515 "Device does not support this command or any other problem...");
<span style="color:blue else
{
<span style="color:green //دستورات زیر برای بیرون کشیدن نام دستگاه از رشته خوانده شده از پورت هست
<span style="color:green //(char)13 کاراکتر اینتر!
DeviceName = DeviceName.Remove(0, DeviceName.IndexOf((<span style="color:blue char)13)).Trim();
DeviceName = DeviceName.Substring(0, DeviceName.IndexOf((<span style="color:blue char)13));
MessageBox.Show(<span style="color:#a31515 "detected successfully" + Environment.NewLine + <span style="color:#a31515 "Device Name:" + Environment.NewLine + DeviceName, <span style="color:#a31515 "", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblDeviceName.Text =<span style="color:#a31515 "Device Name: "+ DeviceName;
btnSend.Enabled = <span style="color:blue true;
}
myport.DiscardOutBuffer();
}
<span style="color:blue catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
<span style="color:blue finally
{
myport.Close();
}
}
}
<span style="color:blue private <span style="color:blue void cmbPortName_SelectedIndexChanged(<span style="color:blue object sender, EventArgs e)
{
btnSend.Enabled = <span style="color:blue false;
}
<span style="color:blue private <span style="color:blue void btnSend_Click(<span style="color:blue object sender, EventArgs e)
{
<span style="color:blue if (txtTel.Text.Trim() != <span style="color:#a31515 "")
{
<span style="color:blue try
{
<span style="color:blue if (!myport.IsOpen)
myport.Open();
<span style="color:green //خالی کردن بافر
myport.DiscardOutBuffer();
myport.DiscardInBuffer();
<span style="color:green //قراردادن دستگاه در حالت متنی
myport.WriteLine(<span style="color:#a31515 "AT+CMGF=1r");
<span style="color:green //دستور ارسال اس ام اس
myport.WriteLine(<span style="color:#a31515 "AT+CMGS=""+txtTel.Text.Trim()+<span style="color:#a31515 ""r");
myport.WriteLine(txtMessage.Text.Trim() + <span style="color:#a31515 x001a);<span style="color:green // x001a (برای انتهای پیام ctrl+z معادل)
Thread.Sleep(500);
<span style="color:blue if (myport.ReadExisting().Contains(<span style="color:#a31515 "ERROR"))
MessageBox.Show(<span style="color:#a31515 "Device does not support this command or any other problem...");
<span style="color:blue else
{
MessageBox.Show(<span style="color:#a31515 "Sent successfully", <span style="color:#a31515 "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
myport.DiscardOutBuffer();
}
<span style="color:blue catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
<span style="color:blue finally
{
myport.Close();
}
}
<span style="color:blue else
{
MessageBox.Show(<span style="color:#a31515 "Enter Tel");
txtTel.Focus();
}
}
<span style="color:blue private <span style="color:blue void button1_Click_1(<span style="color:blue object sender, EventArgs e)
{
help f = <span style="color:blue new help();
f.ShowDialog();
f.Dispose();
}
}
}
[/code]

Please "Help Me Please<br/>
<br/>
How SMS Farsi (Arabic) with a GSM modem, I upload C #

<br/>

View the full article
 
Back
Top