2009-05-28 9 views
5

Windows 응용 프로그램에서 SMS를 보내려고합니다. 코드를 실행했지만 오류가 발생했습니다. 이것은Windows 응용 프로그램을 통해 SMS를 보내는 방법

AT 

OK AT+CMGF=1 

OK AT+CSCA="+9460921985" 

OK AT+CMGS="+9660775564" 

    this is new message 

+CMS ERROR: 500 

이 코드를 사용하고 있습니다.

Public Class Form2 
    Dim number As String = "+9660775564" 
    ''# Dim message As String = TextBox1.Text 
    Dim serialport As New IO.Ports.SerialPort 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    Try With serialport 
     .PortName = "COM5" ''# "COM24" 
     .BaudRate = "9600" 
     .Parity = IO.Ports.Parity.None 
     .DataBits = 8 
     .StopBits = IO.Ports.StopBits.One 
     .Handshake = IO.Ports.Handshake.RequestToSend 
     .DtrEnable = True .RtsEnable = True 
    End With 

    serialport.Open() 
    ''# checks phone status 
    serialport.WriteLine("AT" & vbCrLf) 
    ''# Configures message as SMS 
    serialport.WriteLine("AT+CMGF=1" & vbCrLf) 
    ''# Sets message center number 
    ''# serialport.WriteLine("AT+CSCA=""+447785016005""" & vbCrLf) 
    serialport.WriteLine("AT+CSCA=""+9460921985""" & vbCrLf) 
    ''# Sets destination number 
    serialport.WriteLine("AT+CMGS=""" & number & """" & vbCrLf) 
    ''# Specifies message and sends Ctrl+z 
    serialport.WriteLine(TextBox1.Text & Chr(26)) 
    ''# Displays buffer containing output messages 
    System.Threading.Thread.Sleep(2000) ''# CurrentThread.Sleep(2000) 
    MsgBox(serialport.ReadExisting) 
    serialport.Close() 
    MessageBox.Show("OK") 

    Catch ex As Exception 
    MessageBox.Show(ex.Message) 
    End Try 
End Sub 

미리 도움을 주셔서 감사합니다.

+0

직렬 포트에 무엇이 연결되어 있습니까? – cjk

+0

나는 그 전화를 희망한다 : – samjudson

답변

2

나는 SMS를 작성한 경험이 전혀 없지만 serialPort.WriteLine을 호출 할뿐만 아니라 줄 끝 부분에 vbCrLf를 추가하는 것으로 보입니다.

둘째, 원하는 vbCrLf인지 확인하십시오. 내가 본 것 중 일부는 '캐리지 리턴'을 참조하십시오. 이는 vbCr입니다.

+0

좋은 지점, WriteLine은 자동으로 정확한 라인 종결자를 환경에 추가 할 것이다. – cjk

1

나는 얼마 전에 Microsoft SMS Sender을 우연히 만났습니다. 그러면 도움이 될 것입니다. 그래도 그것을 사용하는 데 주위에있어 ...

0

+ CMS ERROR 500은 (일반적으로) "알 수없는 오류"로 확장됩니다.


If sending fails, for example, if a message is too long, the result code depends on the current setting of the AT^SM20 command:

If the AT^SM20 equals 1 (factory default) any failure to send a message is responded with "OK". Users should be aware, that despite the "OK" response, the message will not be sent to the subscriber.

If the AT^SM20 equals 0 any failure to send a message is responded with "ERROR". • If sending fails due to timeout, then AT^SM20 =1 causes "+CMS ERROR: Unknown error" to be returned;
AT^SM20 =0 causes "+CMS ERROR: timer expired" to be returned.


아마도 당신이 가진 수 있습니다 시간 제한/연결 문제 : 명령 문서에서 GSM 모뎀에서. 귀하의 모뎀/전화가 서비스에 성공적으로 등록되었는지 즉 AT + COPS에 대한 응답을 확인하십시오. 및 AT + CREG? 명령.

관련 문제