1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

How send SMS Farsi (Arabic) with a GSM modem

Discussion in 'C#' started by afshin160, May 5, 2011.

  1. afshin160

    afshin160 New Member

    Joined:
    May 5, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    How SMS Farsi (Arabic) with a GSM modem

    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.

    The following code I'm easy to send messages.


    Code:
    
    [COLOR=blue]using[/COLOR] System;
    [COLOR=blue]using[/COLOR] System.Collections.Generic;
    [COLOR=blue]using[/COLOR] System.ComponentModel;
    [COLOR=blue]using[/COLOR] System.Data;
    [COLOR=blue]using[/COLOR] System.Drawing;
    [COLOR=blue]using[/COLOR] System.Text;
    [COLOR=blue]using[/COLOR] System.Windows.Forms;
    [COLOR=blue]using[/COLOR] System.IO.Ports;
    [COLOR=blue]using[/COLOR] System.Threading;
    [COLOR=blue]namespace[/COLOR] sms_at_command
    {
     [COLOR=blue]public[/COLOR] [COLOR=blue]partial[/COLOR] [COLOR=blue]class[/COLOR] Form1 : Form
     {
     SerialPort myport = [COLOR=blue]new[/COLOR] SerialPort();
     [COLOR=blue]string[/COLOR] DeviceName = [COLOR=#A31515]""[/COLOR];
     [COLOR=blue]public[/COLOR] Form1()
     {
      InitializeComponent();
      [COLOR=green]//تنظیمات پورت[/COLOR]
      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 = [COLOR=blue]true[/COLOR];
     }
     [COLOR=blue]private[/COLOR] [COLOR=blue]void[/COLOR] Form1_Load([COLOR=blue]object[/COLOR] sender, EventArgs e)
     {
      cmbPortName.SelectedIndex = 0;
     }
     [COLOR=blue]private[/COLOR] [COLOR=blue]void[/COLOR] button1_Click([COLOR=blue]object[/COLOR] sender, EventArgs e)
     {
      [COLOR=blue]if[/COLOR] (cmbPortName.Text.Trim() != [COLOR=#A31515]""[/COLOR])
      {
      [COLOR=blue]try[/COLOR]
      {
       lblDeviceName.Text = [COLOR=#A31515]""[/COLOR];
       myport.PortName = cmbPortName.Text.Trim();
       [COLOR=blue]if[/COLOR] (!myport.IsOpen)
       myport.Open();
       myport.DiscardOutBuffer();[COLOR=green]//خالی کردن بافر[/COLOR]
       myport.WriteLine([COLOR=#A31515]"AT+cgmm\r"[/COLOR]);[COLOR=green]//دستور شناخت مدل دستگاه[/COLOR]
       Thread.Sleep(500);
       DeviceName = myport.ReadExisting();
       [COLOR=blue]if[/COLOR] (DeviceName.Contains([COLOR=#A31515]"ERROR"[/COLOR]))
       MessageBox.Show([COLOR=#A31515]"Device does not support this command or any other problem..."[/COLOR]);
       [COLOR=blue]else[/COLOR]
       {
       [COLOR=green]//دستورات زیر برای بیرون کشیدن نام دستگاه از رشته خوانده شده از پورت هست[/COLOR]
       [COLOR=green]//(char)13 کاراکتر اینتر![/COLOR]
       DeviceName = DeviceName.Remove(0, DeviceName.IndexOf(([COLOR=blue]char[/COLOR])13)).Trim();
       DeviceName = DeviceName.Substring(0, DeviceName.IndexOf(([COLOR=blue]char[/COLOR])13));
       MessageBox.Show([COLOR=#A31515]"detected successfully"[/COLOR] + Environment.NewLine + [COLOR=#A31515]"Device Name:"[/COLOR] + Environment.NewLine + DeviceName, [COLOR=#A31515]""[/COLOR], MessageBoxButtons.OK, MessageBoxIcon.Information);
       lblDeviceName.Text =[COLOR=#A31515]"Device Name: "[/COLOR]+ DeviceName;
       btnSend.Enabled = [COLOR=blue]true[/COLOR];
       }
       myport.DiscardOutBuffer();
      }
      [COLOR=blue]catch[/COLOR] (Exception ex)
      {
       MessageBox.Show(ex.Message);
      }
      [COLOR=blue]finally[/COLOR]
      {
       myport.Close();
      }
      }
     }
     [COLOR=blue]private[/COLOR] [COLOR=blue]void[/COLOR] cmbPortName_SelectedIndexChanged([COLOR=blue]object[/COLOR] sender, EventArgs e)
     {
      btnSend.Enabled = [COLOR=blue]false[/COLOR];
     }
     [COLOR=blue]private[/COLOR] [COLOR=blue]void[/COLOR] btnSend_Click([COLOR=blue]object[/COLOR] sender, EventArgs e)
     {
      [COLOR=blue]if[/COLOR] (txtTel.Text.Trim() != [COLOR=#A31515]""[/COLOR])
      {
      [COLOR=blue]try[/COLOR]
      {
       [COLOR=blue]if[/COLOR] (!myport.IsOpen)
       myport.Open();
       [COLOR=green]//خالی کردن بافر[/COLOR]
       myport.DiscardOutBuffer();
       myport.DiscardInBuffer();
       [COLOR=green]//قراردادن دستگاه در حالت متنی[/COLOR]
       myport.WriteLine([COLOR=#A31515]"AT+CMGF=1\r"[/COLOR]);
       [COLOR=green]//دستور ارسال اس ام اس[/COLOR]
       myport.WriteLine([COLOR=#A31515]"AT+CMGS=\""[/COLOR]+txtTel.Text.Trim()+[COLOR=#A31515]"\"\r"[/COLOR]);
       myport.WriteLine(txtMessage.Text.Trim() + [COLOR=#A31515]'\x001a'[/COLOR]);[COLOR=green]// \x001a (برای انتهای پیام ctrl+z معادل)[/COLOR]
       Thread.Sleep(500);
       [COLOR=blue]if[/COLOR] (myport.ReadExisting().Contains([COLOR=#A31515]"ERROR"[/COLOR]))
       MessageBox.Show([COLOR=#A31515]"Device does not support this command or any other problem..."[/COLOR]);
       [COLOR=blue]else[/COLOR]
       {
       MessageBox.Show([COLOR=#A31515]"Sent successfully"[/COLOR], [COLOR=#A31515]""[/COLOR], MessageBoxButtons.OK, MessageBoxIcon.Information);
       }
       myport.DiscardOutBuffer();
      }
      [COLOR=blue]catch[/COLOR] (Exception ex)
      {
       MessageBox.Show(ex.Message);
      }
      [COLOR=blue]finally[/COLOR]
      {
       myport.Close();
      }
      }
      [COLOR=blue]else[/COLOR]
      {
      MessageBox.Show([COLOR=#A31515]"Enter Tel"[/COLOR]);
      txtTel.Focus();
      }
     }
     [COLOR=blue]private[/COLOR] [COLOR=blue]void[/COLOR] button1_Click_1([COLOR=blue]object[/COLOR] sender, EventArgs e)
     {
      help f = [COLOR=blue]new[/COLOR] help();
      f.ShowDialog();
      f.Dispose();
     }
     }
    }
    
    
    
    Please "Help Me Please

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

Share This Page