Click here to Skip to main content
15,891,762 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,I want to send message by my number using C# console Application in other numbers. However i used following code.This is giving given Port not exist and The port is closed. What port i should use.
What requirement is needed. Actually i have to make .EXE file of this application.So that after entering message ,message should directly go to other number.


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
using System.Text.RegularExpressions;

namespace Message_port
{
    class Program
    {

        static void Main(string[] args)
        {
           
             SerialPort e = new SerialPort();
                e.PortName = "COM4";
                e.BaudRate = 230400;
                e.Parity = Parity.None;
                e.DataBits = 8;
                e.StopBits = StopBits.One;
                if (!(e.IsOpen))
                {
                    try
                    {
                        e.Open();
                    }
                    catch (Exception m)
                    {

                        Console.WriteLine(m.Message);
                    }
                }
              //  ExecCommand("AT", 300, "No phone connected at " + ".");
                    e.Write("AT" + (char)13);

                    e.Write("AT+CPIN?" + (char)13);

                    e.Write("AT+CREG?" + (char)13);

                    e.Write("AT+CMGF=1" + (char)13);
                    e.WriteLine("AT+CSCA=" + "9760783135" + (char)13);
                    e.WriteLine("AT+CMGS=" + "9971335835" + (char)13);
                    e.WriteLine("message" + (char)13);

                    e.Write(""+(char)26);

        }
    }
}
Posted
Updated 24-Jun-14 20:27pm
v2

1 solution

Hi,

Please check the below link. Hope it helps.

http://www.c-sharpcorner.com/UploadFile/b8d90a/send-sms-using-C-Sharp-net/

Regards,
Anand Subramanian.
 
Share this answer
 
Comments
Ayush Nautiyal 25-Jun-14 2:39am    
Actually i am talking about console application. and after want to .exe file of that...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900