Text messaging

Status
Not open for further replies.

pcbres12

Baseband Member
Messages
34
Hello all,

I want to make a program, where you can enter your cell number and provider and hit a submit button. In turn when you submit your info you will recive text messages on your phone. What language will I need to write this in? Is there a place where something like this can be downloaded? Could someone give me an example of what needs to be done???
 
I actually wrote something similar last month. It's a basic email and text messaging system written in C#. Let me know if you want it.
 
I've tried to upload the files a couple times to my site but it's failed. I called the hosting company and they said it should be fixed by tonight so hopefully that means in 6 hours or so.
 
Go with megaupload if you still have problems, I would be interested, also ;)

Cheers,

~ Tkey
 
Its an easy application to write, just make a PHP/Ruby/Python script which sends an email to the phone number, youll need the providers Email to SMS portal address (Verizon is number@vtext.com. If you wanted to send SMS to more providers, youd need to figure out if they have some kind of email-to-SMS portal system as well.
I don't like that your just handing code over (nevertheless C# code), as a programmer you should encourage learning by having those guys figure it out and giving them little hints if they cant find it on their own. Ah well, perhaps I am just old fashioned!
 
Alright I give up on my hosting. Found a server with my college that supports .aspx pages.

Here is where a working version of the page is: Chris Bornhoft - Email System. Of course no email will work because as you see in the code below the SMTP server I used is called mailserver.com which doesn't exist. But I have used it with my own site's email and yahoo's email and they both work.

Here is the ASP.NET code:

Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="email.aspx.cs" Inherits="extra_email" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Chris Bornhoft - Email System</title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            font-family: Arial;
        }
        .style3
        {
            font-family: Arial;
            width: 177px;
        }
    </style>
</head>
<body>

    <form id="form1" runat="server">

    <h3 class="style2">Email System</h3>

    <table class="style1">
        <tr>
            <td class="style3" valign="top">
                <span class="style2">Select a Message Type:</span> </td>
            <td class="style2">
        <asp:DropDownList ID="ddl_type" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="ddl_type_SelectedIndexChanged">
            <asp:ListItem Value="Email">Email</asp:ListItem>
            <asp:ListItem Value="Text">Text</asp:ListItem>
        </asp:DropDownList>
                <br />
                <br />
            </td>
        </tr>
        <tr>
            <td class="style3" valign="top">
                <asp:Label ID="lbl_to" runat="server" Text="To:"></asp:Label>
            </td>
            <td class="style2">
                <asp:TextBox ID="tbx_to" runat="server" Width="200px"></asp:TextBox>
                <br />
            </td>
        </tr>
        <tr>
            <td class="style3" valign="top">
                <asp:Label ID="lbl_user" runat="server" Text="User:"></asp:Label>
            </td>
            <td class="style2">
                <asp:TextBox ID="tbx_user" runat="server" Width="200px"></asp:TextBox>
                <br />
            </td>
        </tr>
        <tr>
            <td class="style3" valign="top">
                <asp:Label ID="lbl_pass" runat="server" Text="Password:"></asp:Label>
            </td>
            <td class="style2">
                <asp:TextBox ID="tbx_pass" runat="server" Width="200px"></asp:TextBox>
                <br />
            </td>
        </tr>
        <tr>
            <td class="style3" valign="top">
                <asp:Label ID="lbl_cc" runat="server" Text="CC:"></asp:Label>
            </td>
            <td class="style2">
                <asp:TextBox ID="tbx_cc" runat="server" Width="200px"></asp:TextBox>
                <br />
                <br />
                <br />
            </td>
        </tr>
        <tr>
            <td class="style3" valign="top">
                Subject:</td>
            <td class="style2">
                <asp:TextBox ID="tbx_subject" runat="server" Width="200px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style3" valign="top">
                Message:</td>
            <td class="style2">
                <asp:TextBox ID="tbx_message" runat="server" Height="300px" Width="600px" 
                    TextMode="MultiLine"></asp:TextBox>
            </td>
        </tr>
    </table>

    <asp:Button ID="btn_send" runat="server" Text="Send" Width="80px" onclick="btn_send_Click"/>

    <br />
    <p>
        <asp:Label ID="lbl_error" runat="server" style="font-family: Arial"></asp:Label>
    </p>

</form>

</body>
</html>

Here is the server side C# code:

Code:
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
using System.Net.Mail;
using System.Collections;


public partial class extra_email : System.Web.UI.Page
{
    protected void ddl_type_SelectedIndexChanged(object sender, EventArgs e)
    {
        if(ddl_type.SelectedValue == "Email")
        {
            lbl_to.Text = "To:";
            lbl_user.Text = "User:";
            lbl_pass.Visible = true;
            tbx_pass.Visible = true;
            lbl_cc.Visible = true;
            tbx_cc.Visible = true;
        }
        else if (ddl_type.SelectedValue == "Text")
        {
            lbl_to.Text = "Phone Number:";
            lbl_user.Text = "Your Phone Number:";
            lbl_pass.Visible = false;
            tbx_pass.Visible = false;
            lbl_cc.Visible = false;
            tbx_cc.Visible = false;
        }
    }
    
    protected void btn_send_Click(object sender, EventArgs e)
    {
        string to = tbx_to.Text;
        string from = tbx_user.Text + "@mailserver.com";
        string user = tbx_user.Text;
        string pass = tbx_pass.Text;
        string cc = tbx_cc.Text;
        string subject = tbx_subject.Text;
        string message = tbx_message.Text;

        MailAddress From = new MailAddress(from);
        MailAddress To = new MailAddress(to);
        MailMessage Mail = new MailMessage(From, To);

        //NetworkCredential UserInfo = new NetworkCredential(user, pass);

        Mail.Subject = subject;
        Mail.Body = message;

        SmtpClient MailServer = new SmtpClient("mailserver.com", 465);

        /*
        MailServer.EnableSsl = true;
        MailServer.UseDefaultCredentials = false;
        MailServer.Credentials = UserInfo;
        */

        if(ddl_type.SelectedValue == "Email")
        {
            if (cc.Length > 0)
            {
                MailAddress c = new MailAddress(cc);
                Mail.CC.Add(c);
            }
        }
        else
        {
            SmtpClient TextServer = new SmtpClient("textserver.com");

            try
            {
                TextServer.Send(Mail);
                lbl_error.Text = "Message successfully sent.";
            }
            catch (Exception ex)
            {
                lbl_error.Text = ex.ToString();
            }
        }

        try
        {
            MailServer.Send(Mail);
            lbl_error.Text = "Mail successfully sent.";
        }
        catch (Exception ex)
        {
            lbl_error.Text = ex.ToString();
        }
    }
}

I did not implement any textbox validation so if you leave an email box blank the page will crash. If you need validation I can easily assist you with it.

Hope it helps. If you have any questions on what something means feel free to ask.
 
Now, with this code, is there a way to make it so that a person can text to a number and the computer will throw out a random message at them? Also can I just copy and paste this in a notepad doc, as it is on here?
 
Status
Not open for further replies.
Back
Top Bottom