Monday, 18 March 2013

SEND SMS


Introduction:
This article describes a simple way to send text messages to a cellular phone from within a C# desktop application.  The source code provided includes a relatively good list of carriers to simplify the task of connecting with a cell phone and the task itself is really no more difficult than sending an email message through a desktop or web based application.
Getting Started:
In order to begin, unzip the downloaded files and open the project provided.  Within the project you will find one main class:  frmMain.cs.  The main form is a windows application form and it contains a few controls necessary to capture the fields needed to properly form the message.  These fields include:
  • Recipient's Phone Number:  Captures the recipient's cellular telephone number (10 digit)
  • Recipient's Carrier:  Captures the recipient's carrier.
  • Sender's email address:  Captures the sender's email address.
  • Sender's email server:  Captures the name of the sender's email server 
  • Message Subject Line:  Captures the message's title or subject
  • Message Body:  Captures the sender's message content.
The application is simple but could easily be improved by validating each of the required fields through the use of regular expressions or by at least validating that the text associated with each of the text boxes is not an empty string.  To maintain the simplicity of the project, little in the way of error handling has been included.
The following figure (Figure 1) shows a properly configured collection of input fields in use:

Figure 1: The Demonstration Application in Use
A quick review of the code will reveal that there is little going on there.  The following imports were added to the top of the class:
using System;
using System.Net.Mail;
The System.Net.Mail import brings in the support necessary to transmit the messages generated using the application.  Following the imports and the class declaration, there is a declarations region identified and within that region is a collection of private member variables; these private member variables are created in order to supply each of the required elements of the message.
#Region "Declarations"

// message elements
   private string mMailServer;
   private string mTo;
   private string mFrom;
   private string mMsg;
   private string mSubject;
 
#End Region
At this point, the only thing left to do in code is to  write the following  three methods:
   
private void frmMain_Load(System.Object sender, System.EventArgs e)
     {
        // set up the carriers list - this is a fair list, you may wish to
        // research the topic and add others, it took a while to generate this
        // list...
        cboCarrier.Items.Add("@itelemigcelular.com.br");
        cboCarrier.Items.Add("@message.alltel.com");
        cboCarrier.Items.Add("@message.pioneerenidcellular.com");
        cboCarrier.Items.Add("@messaging.cellone-sf.com");
        cboCarrier.Items.Add("@messaging.centurytel.net");
        cboCarrier.Items.Add("@messaging.sprintpcs.com");
        cboCarrier.Items.Add("@mobile.att.net");
        cboCarrier.Items.Add("@mobile.cell1se.com");
        cboCarrier.Items.Add("@mobile.celloneusa.com");
        cboCarrier.Items.Add("@mobile.dobson.net");
        cboCarrier.Items.Add("@mobile.mycingular.com");
        cboCarrier.Items.Add("@mobile.mycingular.net");
        cboCarrier.Items.Add("@mobile.surewest.com");
        cboCarrier.Items.Add("@msg.acsalaska.com");
        cboCarrier.Items.Add("@msg.clearnet.com");
        cboCarrier.Items.Add("@msg.mactel.com");
        cboCarrier.Items.Add("@msg.myvzw.com");
        cboCarrier.Items.Add("@msg.telus.com");
        cboCarrier.Items.Add("@mycellular.com");
        cboCarrier.Items.Add("@mycingular.com");
        cboCarrier.Items.Add("@mycingular.net");
        cboCarrier.Items.Add("@mycingular.textmsg.com");
        cboCarrier.Items.Add("@o2.net.br");
        cboCarrier.Items.Add("@ondefor.com");
        cboCarrier.Items.Add("@pcs.rogers.com");
        cboCarrier.Items.Add("@personal-net.com.ar");
        cboCarrier.Items.Add("@personal.net.py");
        cboCarrier.Items.Add("@portafree.com");
        cboCarrier.Items.Add("@qwest.com");
        cboCarrier.Items.Add("@qwestmp.com");
        cboCarrier.Items.Add("@sbcemail.com");
        cboCarrier.Items.Add("@sms.bluecell.com");
        cboCarrier.Items.Add("@sms.cwjamaica.com");
        cboCarrier.Items.Add("@sms.edgewireless.com");
        cboCarrier.Items.Add("@sms.hickorytech.com");
        cboCarrier.Items.Add("@sms.net.nz");
        cboCarrier.Items.Add("@sms.pscel.com");
        cboCarrier.Items.Add("@smsc.vzpacifica.net");
        cboCarrier.Items.Add("@speedmemo.com");
        cboCarrier.Items.Add("@suncom1.com");
        cboCarrier.Items.Add("@sungram.com");
        cboCarrier.Items.Add("@telesurf.com.py");
        cboCarrier.Items.Add("@teletexto.rcp.net.pe");
        cboCarrier.Items.Add("@text.houstoncellular.net");
        cboCarrier.Items.Add("@text.telus.com");
        cboCarrier.Items.Add("@timnet.com");
        cboCarrier.Items.Add("@timnet.com.br");
        cboCarrier.Items.Add("@tms.suncom.com");
        cboCarrier.Items.Add("@tmomail.net");
        cboCarrier.Items.Add("@tsttmobile.co.tt");
        cboCarrier.Items.Add("@txt.bellmobility.ca");
        cboCarrier.Items.Add("@typetalk.ruralcellular.com");
        cboCarrier.Items.Add("@unistar.unifon.com.ar");
        cboCarrier.Items.Add("@uscc.textmsg.com");
        cboCarrier.Items.Add("@voicestream.net");
        cboCarrier.Items.Add("@vtext.com");
        cboCarrier.Items.Add("@wireless.bellsouth.com");
   }
   private void btnSend_Click(System.Object sender, System.EventArgs e)
   {
     // Collect user input from the form and stow content into
     // the objects member variables
        mTo = Trim(txtPhoneNumber.Text) & Trim(cboCarrier.SelectedItem.ToString());
        mFrom = Trim(txtSender.Text);
        mSubject = Trim(txtSubject.Text);
        mMailServer = Trim(txtMailServer.Text);
        mMsg = Trim(txtMessage.Text);
     // Within a try catch, format and send the message to
     // the recipient.  Catch and handle any errors.
         try
           {
            MailMessage message= new MailMessage(mFrom, mTo, mSubject, mMsg);
            SmtpClient mySmtpClient=new SmtpClient(mMailServer);
            mySmtpClient.UseDefaultCredentials = True;
            mySmtpClient.Send(message);
            MessageBox.Show("The mail message has been sent to " & message.To.ToString(), "Mail", MessageBoxButtons.OK, MessageBoxIcon.Information);
           }
         catch(FormatException ex)
           {
            MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
           }
         catch(SmtpException ex)
           {
            MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
           }
        catch(Exception ex)
           {
            MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
           }
        }
        private void btnExit_Click(System.Object sender, System.EventArgs e)
          { 
          // Upon user's request, close the application
             Application.Exit();
          }

At this point, the application should be complete you may wish to build the solution and test it.  Even though this example was intended to be simple, the overall concept may be used within an application to do some seemingly complex jobs.  For example, if you were tasked with writing an application that monitored some sort of trend information such as a daily stock price, and were to alert a group of end users whenever the stock price exceeded some predetermined, agreed upon value, you could do something such as looping through a collection of users subscribing to the stock price monitoring service and direct a text message to each of these users indicating that the watched stock had surpassed the threshold value. 
Also please note that, whilst it does cost you a dime to send a message to a cell phone in this manner, it may well cost the recipient something to receive it.  Bearing that in mind, as you test your version of the code, be mindful of an expenses you may be generating for yourself (if, for example, you are sending messages to yourself) or another person.

Login using Stored Procedure

-->


First create one table named Emp_Login in the SQL database which looks as in the following image:

Insert the One Record in the table as:
Insert into Emp_Login (userName,Password) values ('abcd2013','abcdefgh')
 
In the above table the usename column is used to store the User Name and Password is for the user's Password.
 
Now let us create a Stored Procedure named Emplogin as follows:
 

Create  procedure Emplogin
(
@Usename Varchar (20),
@Password varchar (10)
)
as
Begin
Select COUNT(*)from Emp_Login where username=@Usename and password=@Password 
End
 

In the above Stored Procedure named Emplogin the variable @Usename is used for the username and @Password is used for the password. The select query that I have written in the beginning counts the number of users from the table whose name matches with the exact two variables; that is @Usename and @Password which comes from the front end user input page.
 
Now create the project named Loginapplication or you can specify any name as:
  1. "Start" - "All Programs" - "Microsoft Visual Studio 2008/2010".
  2. "File" - "New Project" - "C#" - "Empty Project" (to avoid adding a master page).
  3. Give the web site a name such as Login or another as you wish and specify the location.
  4. Then right-click on Solution Explorer - "Add New Item" - Signin.aspx page for Login Credential and Welcome.aspx for redirecting after successful login.
  5. Drag and drop two buttons, one Label and two textBoxes on the <form> section of the Default aspx page.
Then the  <form> section of the Default aspx page looks as in the following:
 
Default page.png
 
Then double-click on btn2 and write the following code in the Button_click function as:
 

 protected void Button2_Click (objectsender, EventArgs e)
 {
     connection();
     query = "Emplogin";   //stored procedure Name
     SqlCommand com = new  SqlCommand(query, con);

     com.CommandType= CommandType.StoredProcedure;

     com.Parameters.AddWithValue("@Usename", TextBox1.Text.ToString());   //for username 
     com.Parameters.AddWithValue("@Password", TextBox2.Text.ToString());  //for password
     int usercount = (Int32)com.ExecuteScalar();// for taking single value
     if (usercount == 1)  // comparing users from table 
     {
         Response.Redirect("Welcome.aspx");  //for sucsseful login
     }
     else
     {
         con.Close();
         Label1.Text = "Invalid User Name or Password";  //for invalid login
     }
}
The most important part of the preceding code is the If condition part, I have used the one integer variable user count which is used to count the single value from the Stored Procedure using ExecuteScalar, if the records are found in the table it returns 1 then the page is redirected to the Welcome page otherwise it gives Invalid user Name or Password. 
 Which we are already entered into the table at the creation of the table.




Saturday, 2 March 2013

Search Now Learn Now

-->


LEARN NOW- SEO SEARCH ENGINE OPTIMIZATION (click on Image)

ASP.NET Tutorials For WEB Delopers (Click on Image)


JavaScript Tutorials
Microsoft SQL Server

Lesson 15

Learnt how to optimize keywords, title, alt, meta tags, anchor and other text from SEO point of view.
So in brief ethical strategies for achieving optimal ranking in the search engines are:
  • All Pages Must Conform with W3C Standards
  • Keyword Density is Never Abusive
  • Always Include: Robots.txt, Sitemap.xml, & Urllist.txt
  • Keywords are Prominent in the Title, META tags, & Headings
  • ALT Tags and Title Tags are Not Forgotten
  • Nomenclature is Fundamental to Being Indexed
 Keep visiting to us, Happy Learning!

Lesson 14

There are various other tips related to SEO.

Do the followings:

There are various other tips which can help you to optimize your web site for many Search Engines.
  • Create logs of pages and each page should however contain a minimum of about 200 visible words of text to maximize relevance with Google.
  • Create a Sitemap, Help, FAQ, About Us, Link to Us, Copyright, Disclaimer, Privacy Policy pages on mandatory basis.
  • Create a home page link to each and every web page and provide easy navigation through all the pages.
  • Pay attention to your dynamic page URLs. Google can crawl and index dynamic pages as long as you don't have more than 2 parameters in the URL.
  • Check your complete site for broken links. Broken links will reduce your other pages rank as well.

Don't do the followings:

  • Don't keep hidden text on your web pages.
  • Don't create alt image spamming by putting wrong keywords.
  • Don't use meta tags stuffing.
  • Don't use frames and flash on your site.
  • Don't exchange your links with black listed sites.
  • Don't try to fool your site visitors by using miss spelled keyword.
  • Don't send spam emails to thousand of email IDs.
  • Don't use too much graphics on your site.
  • Don't create too many doorway pages.
  • Don't try to create duplicate content of pages.
  • Don't submit your website many times in a single search engine.
  • Don't use sub-directory depth more than 1-2.
  • Don't create too many dynamic pages. Try to convert them into static pages.
  • Don't bloat your pages with code.
  • Don't nest your pages.

Lesson 12

Web site Crawler will go to a site again and again whose ranking in Search Engine is high. You can verify this fact by putting your site on a high rank site. If your site link is available on a high rank web site then you have 99.99% chances that you site will be indexed with-in 24Hrs.

How to increase Link Popularity ?

There are various ways of increasing your web site link popularity. I'm listing out some important tips which are easily doable.
  • Submit your site in popular search engines manually. Don't go for automated submission.
  • Get your site listed in Open Directory Projects like dmog.org, yahoo.com. Getting listed in these directories will give your site a boost in link popularity and improve search engine ranking in other search engines.
  • Provide high quality content - people will naturally link to your site if you have what they want and no where is available.
  • Leverage your personal relationsrelations with other webmasters. Put your site link on their sites. One way links often count for more than reciprocal links.
  • Participate in Link Exchange Program. Find top 20 sites doing the same business and contact them for reciprocal links. Link exchange between unrelated sites might affect the ranking of websites in the Search Engine.
  • If you are subscribed in a forum and forum does not have any restriction to keep your site link as your signature then it can help you to increase your site popularity.
  • Submit your site to bookmark sites like DIGG, and Slashdot etc. Before submitting please go through their spam policy.
  • Write good articles in blogging sites and give few references of your links with-in that article.
  • Keep providing good content to your site visitors. Try to keep them busy on your site. If possible create forums, news letters, blogs etc.
There are other ways but you need to spend some dollars to go for such alternative.
  • Buy a place on high rank website where you can put your link.
  • Subscribe for google's Adwords program to drive traffic towards your site.
  • You can go for alternative advertising option to increase the number of hits on your site which will result in your site link popularity.

Lesson 12

There are following tasks which should be taken care by SEO experts
  • Code validation and clean up - Ensure that code is SE Friendly and standards compliant.
  • Site Structure - Building a semantic structure/theme and ensure URL's are spider friendly.
  • On Page optimization - Page Title, copy writing, Call to action etc.
  • Quality link building - Securing one way links from relevant sites.
  • Keyword research - Building a list of key-phrases relevant to your business.
  • Creating Quality Content - Build optimized pages around terms discovered through keyword research.
  • Off Page Optimization - Blogs, Press Releases, Article Submissions
If you are confident that you have the required skills then you can take care of doing all the above activities otherwise its worth taking help from SEO Companies or to hire any SEO Specialist.

Choosing a SEO Expert or Company:

This is most difficult part to choose a correct SEO Expert or SEO Company. But we are giving you few guidelines which can help you for the same.
  • Start searching through your friends and business partners.
  • Post your queries in SEO Forums to get feedback from the community.
  • Check other sites rank which they already have optimized.
  • Don't go for SEO companies doing automated submission etc.
  • Don't go for SEO companies doing Balk Hat tricks.
  • Don't look for cheap SEO because of some pennies you can loss more. But take care, high price also does not guarantee high quality.
  • Take guarantee if possible for a particular rank and any particular search engine.
  • User SEO Expert or Company name in Google to find more information about them.
  • Don't go just because of their fancy site and good article available on their site.
  • Don't go testimonials available on their sites.