473,322 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

ASP.NET: Sending SMS - BulkSMSGateway returns error 4006

87
Hi,

I use BulkSMSGateway - ATSMS.dll for sending SMS from ASP.NET.

When I click Connect button, I am able to connect to the mobile using bluetooth successfully from my WebPage.

But when i click Send button, the oGsmModem returns error
e.errorcode=4006 in the oGsmModem_OutboxSMSSent event.

But i can send SMS successfully using VB.NET Windows Appication.

Why it returns error in web form alone?

Please help me to send SMS from my Web Page.

Thanks in advance...
Apr 2 '10 #1
3 4017
CroCrew
564 Expert 512MB
Hello Ananthu,

A few years back I created an example in Classic ASP for a member to send SMS text to phones via a website. [See here]

I took that code and changed it up to work in the dot.net environment. I have not tested it out but I think it should work for you. This way you don’t have to use 3rd party addons.

Happy Coding,
CroCrew~


Default1.aspx
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default1.aspx.vb" Inherits="Default1" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4.     <head runat="server">
  5.         <title></title>
  6.     </head>
  7.     <body>
  8.         <form id="form1" runat="server">
  9.             <div>
  10.                 <table border="0"> 
  11.                     <tr> 
  12.                         <td>Phone Number:</td> 
  13.                         <td><asp:TextBox ID="PhoneNumber" runat="server" /><font size="1">(only enter the numbers) example 6045555555</font></td> 
  14.                     </tr> 
  15.                     <tr> 
  16.                         <td>Select Your Carrier</td> 
  17.                         <td> 
  18.                             <asp:DropDownList ID="Carrier" runat="server">
  19.                                 <asp:ListItem Value="@tmomail.net" Text="T-Mobile (USA)" />
  20.                                 <asp:ListItem Value="@message.alltel.com" Text="Alltel Wireless" />
  21.                                 <asp:ListItem Value="@mms.att.net" Text="AT&T Mobility (formerly Cingular)" />
  22.                                 <asp:ListItem Value="@cingularme.com" Text="Cingular (Postpaid)" />
  23.                                 <asp:ListItem Value="@cwemail.com" Text="Centennial Wireless" />
  24.                                 <asp:ListItem Value="@cingularme.com" Text="Cingular (GoPhone prepaid)" />
  25.                                 <asp:ListItem Value="@fido.ca" Text="Fido (Canada)" />
  26.                                 <asp:ListItem Value="@pcs.rogers.com" Text="Rogers (Canada)" />
  27.                                 <asp:ListItem Value="@messaging.sprintpcs.com" Text="Sprint (PCS)" />
  28.                                 <asp:ListItem Value="@page.nextel.com" Text="Sprint (Nextel)" />
  29.                                 <asp:ListItem Value="@vtext.com" Text="Verizon" />
  30.                                 <asp:ListItem Value="@vmobl.com" Text="Virgin Mobile (USA)" />
  31.                                 <asp:ListItem Value="@vmobile.ca" Text="Virgin Mobile (Canada)" />
  32.                                 <asp:ListItem Value="@mmst5.tracfone.com" Text="Tracfone (prepaid)" />
  33.                             </asp:DropDownList>
  34.                         </td> 
  35.                     </tr> 
  36.                     <tr> 
  37.                         <td colspan="2"> 
  38.                             <textarea id="YourMessage" runat="server" cols="142" rows="5" style="width:500px">Only 142 characters can be sent!</textarea> 
  39.                         </td> 
  40.                     </tr> 
  41.                     <tr><td colspan="2"><asp:Button ID="Send" runat="server" Text="Send Message to Phone" /></td></tr> 
  42.                 </table> 
  43.                 <p>*Standard text messaging rates apply.</p>
  44.             </div>
  45.         </form>
  46.     </body>
  47. </html>
  48.  

Default1.aspx.vb
Expand|Select|Wrap|Line Numbers
  1. Imports System.Net.Mail
  2.  
  3. Partial Class Default1
  4.     Inherits System.Web.UI.Page
  5.  
  6.     Protected Sub Send_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Send.Click
  7.         Try
  8.             Dim oMail As New MailMessage
  9.             With oMail
  10.                 .From = New MailAddress("YourMail@MyEmail.com")
  11.                 .To.Add(PhoneNumber.Text & Carrier.SelectedValue)
  12.                 .Subject = ""
  13.                 .Body = YourMessage.Value
  14.                 .IsBodyHtml = True
  15.             End With
  16.  
  17.             Dim oSMTP As New SmtpClient
  18.             With oSMTP
  19.                 .Host = "mail.yourServer.org"
  20.                 .Credentials = New System.Net.NetworkCredential("YourMail@MyEmail.com", "Password")
  21.                 .Send(oMail)
  22.             End With
  23.         Catch ex As Exception
  24.             Response.Write(ex)
  25.             Response.End()
  26.         End Try
  27.     End Sub
  28. End Class
  29.  
Here is a link to more Email to SMS Gateways: http://en.wikipedia.org/wiki/List_of...ng_SMS_transit
Apr 2 '10 #2
Ananthu
87
Hi,

This is my code for sending SMS using BulkSMSGateway - ATSMS.dll.
Expand|Select|Wrap|Line Numbers
  1. Imports ATSMS
  2. Imports ATSMS.SMS
  3.  
  4. Partial Class bulkSMS
  5.     Inherits System.Web.UI.Page
  6.  
  7.     Private Const PHONE_BOOK As String = "phonebook.txt"
  8.  
  9.     Private m_strPhoneBook As String
  10.  
  11.     Private WithEvents oGsmModem As New GSMModem
  12.  
  13.     Dim tbl As String
  14.     Dim str As String
  15.     Dim item As Array = Array.CreateInstance(GetType(String), 100)
  16.     Dim cs As clsEPAS = New clsEPAS
  17.     Dim fieldname As String
  18.     Dim fieldvalue As String
  19.  
  20.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As       System.EventArgs) Handles Me.Load
  21.         Dim f As Integer
  22.         f = cs.connect
  23.         If Not IsPostBack Then
  24.             'CheckForIllegalCrossThreadCalls = False
  25.  
  26.             tbl = "tbl_TimeDetails"
  27.             fieldname = "time_session"
  28.             item = cs.getname(tbl, fieldname)
  29.             ddlSession.Items.Add("Select")
  30.             For i As Integer = 0 To item.Length - 1
  31.                 If IsNothing(item(i)) Then
  32.                     Exit For
  33.                 Else
  34.                     ddlSession.Items.Add(item(i))
  35.                 End If
  36.             Next
  37.             For i As Integer = 1 To 50
  38.                 ddlComPort.Items.Add("COM" & i)
  39.             Next
  40.             For i As Integer = 4 To 8
  41.                 ddlDataBit.Items.Add(i)
  42.             Next
  43.         End If
  44.     End Sub
  45.  
  46.     Protected Sub btnConnect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnConnect.Click
  47.         If ddlComPort.Text = String.Empty Then
  48.             Response.Write("COM Port must be selected")
  49.             Return
  50.         End If
  51.  
  52.         oGsmModem.Port = ddlComPort.Text
  53.  
  54.         If ddlBaudRate.Text <> String.Empty Then
  55.             oGsmModem.BaudRate = Convert.ToInt32(ddlBaudRate.Text)
  56.         End If
  57.  
  58.         If ddlDataBit.Text <> String.Empty Then
  59.             oGsmModem.DataBits = Convert.ToInt32(ddlDataBit.Text)
  60.         End If
  61.  
  62.         If ddlStopBit.Text <> String.Empty Then
  63.             Select Case ddlStopBit.Text
  64.                 Case "1"
  65.                     oGsmModem.StopBits = Common.EnumStopBits.One
  66.                 Case "1.5"
  67.                     oGsmModem.StopBits = Common.EnumStopBits.OnePointFive
  68.                 Case "2"
  69.                     oGsmModem.StopBits = Common.EnumStopBits.Two
  70.             End Select
  71.         End If
  72.  
  73.         If ddlFlowControl.Text <> String.Empty Then
  74.             Select Case ddlFlowControl.Text
  75.                 Case "None"
  76.                     oGsmModem.FlowControl = Common.EnumFlowControl.None
  77.                 Case "Hardware"
  78.                     oGsmModem.FlowControl = Common.EnumFlowControl.RTS_CTS
  79.                 Case "Xon/Xoff"
  80.                     oGsmModem.FlowControl = Common.EnumFlowControl.Xon_Xoff
  81.             End Select
  82.         End If
  83.  
  84.         Try
  85.             oGsmModem.Connect()
  86.         Catch ex As Exception
  87.             Response.Write(ex.Message)
  88.             Return
  89.         End Try
  90.  
  91.         Try
  92.             oGsmModem.NewMessageIndication = True
  93.         Catch ex As Exception
  94.  
  95.         End Try
  96.  
  97.         btnSend.Enabled = True
  98.         btnDisconnect.Enabled = True
  99.         btnConnect.Enabled = False
  100.  
  101.         oGsmModem.AutoDeleteSentMessage = True
  102.         Response.Write("Connected to phone successfully !")
  103.     End Sub
  104.  
  105.     Protected Sub btnDisconnect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
  106.         Try
  107.             oGsmModem.Disconnect()
  108.         Catch ex As Exception
  109.             Response.Write(ex.Message)
  110.         End Try
  111.  
  112.         btnSend.Enabled = False
  113.         btnDisconnect.Enabled = False
  114.         btnConnect.Enabled = True
  115.     End Sub
  116.  
  117.     Private Sub Initialize()
  118.         ' Read from the phone book
  119.         'Dim strContent As String
  120.         'm_strPhoneBook = Application.StartupPath & "\" & PHONE_BOOK
  121.         'If My.Computer.FileSystem.FileExists(m_strPhoneBook) Then
  122.         '    strContent = My.Computer.FileSystem.ReadAllText(m_strPhoneBook)
  123.         '    Dim lines() As String = strContent.Split(ControlChars.CrLf)
  124.         '    Dim i As Integer
  125.         '    For i = 0 To lines.Length - 1
  126.         '        lstMobileNumber.Items.Add(lines(i))
  127.         '    Next
  128.         'End If
  129.     End Sub
  130.  
  131.     Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
  132.         If txtMessage.Text.Trim = String.Empty Then
  133.             Response.Write("Message must not be empty !")
  134.             Return
  135.         End If
  136.  
  137.         If StringUtils.IsUnicode(txtMessage.Text) Then
  138.             oGsmModem.Encoding = Common.EnumEncoding.Unicode_16Bit
  139.         Else
  140.             oGsmModem.Encoding = Common.EnumEncoding.GSM_Default_7Bit
  141.         End If
  142.  
  143.         For Each item As String In lstMobileNumber.Items.ToString
  144.             If item.Trim <> String.Empty Then
  145.                 oGsmModem.SendSMSToOutbox(item.Trim, txtMessage.Text.Trim)
  146.             End If
  147.         Next
  148.  
  149.         Response.Write("Message is queued for sending !")
  150.     End Sub
  151.  
  152.     Private Sub oGsmModem_OutboxSMSSent(ByVal e As ATSMS.OutboxSMSSentEventArgs) Handles oGsmModem.OutboxSMSSent
  153.         If e.ErrorCode > 0 Then
  154.             txtDelivaryReport.Text = txtDelivaryReport.Text & "Error sending message to " & e.DestinationNumber & ". " & e.ErrorDescription & ControlChars.CrLf
  155.         Else
  156.             txtDelivaryReport.Text = txtDelivaryReport.Text & "Message is delivered to " & e.DestinationNumber & ControlChars.CrLf
  157.         End If
  158.     End Sub
  159.  
  160. End Class
I am able to connect to phone successfully. btnSend_click code is working properly. But I get e.errorcode=4006 in oGsmModem_OutboxSMSSent event after btnSend_click event.

The same sms codings work successfully using windows application. But in web application only, it returns e.errorcode=4006. I am unable to send SMS.

Please help me...

Thanks in advance.
Apr 6 '10 #3
CroCrew
564 Expert 512MB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

Thanks,
CroCrew~
Apr 7 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

47
by: Mountain Bikn' Guy | last post by:
Take some standard code such as shown below. It simply loops to add up a series of terms and it produces the correct result. // sum numbers with a loop public int DoSumLooping(int iterations) {...
5
by: aladdinm1 | last post by:
Hi All, I have an annoying trouble with binary serialization. I have a windows forms application which works like a server and keeps sending data to its clients. The data is serialized before...
3
by: Robert A. van Ginkel | last post by:
In news:OZ0W9RsdDHA.2432@TK2MSFTNGP10.phx.gbl... I ask the question how I can see if all the data is on the other side of the connection. I got as answer that I should use the blocking property. I...
7
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
4
by: Lucvdv | last post by:
I have to connect to a server set up by the government, where they used Apache Axis to create a webservice. The code I use to interface to the webservice is generated by wsdl.exe, based on a...
9
by: craig.overton | last post by:
All, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and...
4
by: shamirza | last post by:
4 9 6 18.ATLAS-AJAX Note: - As an IT professional it's useful to know what the difference is between Hype and usefulness. For instance if there is a new technology coming in many programmers...
5
by: WaluigiCubed | last post by:
Hello everyone: I've been working on making some changes to the website for the company that I am currently an intern for. There is a function that they have in one of their files that uses...
2
by: =?Utf-8?B?R3JlZ0lJ?= | last post by:
Hi All, I have some problems with sending UDP packets using Winsock. I tried to send some to a closed port, and according to the documentation on Microsoft MSDN site...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.