Constitution of India – Android Application

[New]To be featured in Sakshat Tablets, an initiative funded by the Ministry of Education, India
[New]Social Features enabled (powered by Socialize)
Constitution of India
The COMPLETE Constitution of India presented in a readable and searchable format. Divided concisely into Parts, Chapters, Sub-Sections and containing the full unedited text of all the Articles. Also Contains 95 Amendments (till date), 12 Schedules and all Central Parliamentary Acts (Net). Everything is Searchable. Scroll through articles by Volume Keys. Current Path is always displayed on the top.
A MUST HAVE for every Indian... and others alike.
This is the ONLY app containing the Constitution of India.
- Full, unedited Article Content of all the 394 Articles.
- Divided into Parts, Sections, Sub-Sections and Article Lists.
- Searchable (Search Key)
- Display's Current Path in every Screen and in every Article so that you know where you are.
- 95 Amendments and their complete contents available
- 12 Schedules from the constitution
- Search in Constitution or Central Parliament Acts.
- Search by Article Content, Chapter Names, Part Names, Sub-Section Names and Article Names in Constitution Mode and Short Title, Act Number, Act Year, Act Objective, Full Act Text & Free Text Search in Central Acts Mode
- Search & Highlight in Amendments/Schedules
- Saves Previous Search State
- Navigate Indexes by Trackball/D-Pad
- Scroll through Articles by Volume Keys
- Tablet Screens Supported (Thanks to Abhitej Velore)
- Neat Presentation in the form of Heading and Description in every Screen
- Zoom by clicking on icons/Pinch zoom in Amendments and Central Acts Screens.
- Text size can be increased/Decreased for Article Content.
- Aesthetic Reading Experience
- Low Memory Resources required
- A good way to teach kid's about the Constitution of India
- Helps Improve the Productivity of people who refer the Constitution regularly.
- Share Article Title, Content or both through SMS, Email or any text related application.
And many more!
Download the application here.
QR Code:
download
Comments in the Android Market for Constitution of India Application:
5 Star Rating - Constitution of Indiaby Ashok (September 11, 2011)
Its very usefull app......love it
5 Star Rating - Constitution of Indiaby personnel management (September 10, 2011)
great job. Thank you....
5 Star Rating - Constitution of India by killer (September 9, 2011)
Excellent app. Must hav
5 Star Rating - Constitution of India by Aasif (September 9, 2011)
Great
5 Star Rating - Constitution of India by Sai (September 7, 2011)
Wonderful app. Thanx 2 the idea
5 Star Rating - Constitution of India by Abhi (September 4, 2011)
wonderful app. thanks
5 Star Rating - Constitution of India by neeraj (September 4, 2011)
Very good app. Every indian must have it. Best developer support.also try IPC , CrPC, CPC by same developer. Thanks.

Inter-State and Intra-State Public Transport Information: Fare & Timings - APSRTC

Given below is the APSRTC Inter/Intra State Transport Information. The previous post was a software for intra-city buses (local public transport), but this provides information about all the buses that the Andhra Pradesh State Operates.


If you are viewing this in e-mail and the page is not displayed properly, then please click here to get the correct display.
Courtesy: http://apsrtc.gov.in/

Hyderabad Bus/Public Transport Information System–Free Application: ABIS

I know it’s been a very very long time since I wrote (my last post was back in Aug), but believe me I have been working like hell.

Well, I developed an interesting application today and I think it’ll turn out to be very useful to the people in Hyderabad or to those who are thinking of visiting Hyderabad (AND use the Public Transportation System).

I call this ABIS – APSRTC Bus Information System.

ABIS - APSRTC BUS INFORMATION SYSTEM

One problem a lot of us face when we visit a new place is finding the RIGHT BUS to take us to the RIGHT Place. There is no internet website/application that allows us to search through the available buses within a city. I visited the APSRTC (Andhra Pradesh Road Transport Corporation) website a week ago, and couldn’t find any searching page where I could find all the bus information. All I found was a Route Map of the City (with Bus No’s of course) and a very big image containing a chart of the routes. Opening the damn thing itself took quite sometime (and I don’t like to blame it on my broadband Smile). So I decided to make an application to solve this particular problem. I hunted around and found some info here and some info there. Aggregated all the assorted information and sat down to make what seemed to be a very dull and boring process of developing an application. And at the end of the day, it turned out to be pretty good. So good that I can distribute it as an application. As with the Gmailer application I’ve developed before, this application also requires JRE to run which you can get here or here. The advantage of using Java for developing an application is you can run the application in virutally every OS – Windows, Macintosh, Linux (All Distributions), Solaris, etc.

Download ABIS Here (Size: 216 KB)
Click here for ABIS (APSRTC Bus Information System) Project Page on Google and here for Source Forge Project Page.

Here is a screenshot of ABIS.

APSRTC Bus Schedule Information - Felix

The first tab in the application contains all the buses in and around Hyderabad, the capital city of Andhra Pradesh, India. The fields present in this tab are

  • Route/Bus No’s
  • From
  • To
  • Via (list of places the bus goes through)
  • Up Journey-First Bus
  • Up Journey-Last Bus
  • Down Journey-First Bus
  • Down Journey-Last Bus
  • Peak Hours Frequency
  • Slack Hours Frequency.

A search form is present above the table to search through the list. Two buttons ‘Clear’ – clears the above table, ‘Load All’ – Loads all the results are present to make things easier.

Hi-Tech City Felix

The second tab contains information about the Buses that operate in and around Hi-Tech City, the Tech Hub of Hyderabad (AP). The fields present in this are:

  • Depot
  • Service No
  • Type
  • Time of Departure
  • Route No.
  • From
  • To

Simple and to-the-point application. That’s it.
Just for Kicks, I’ve added a Look and Feel Menu which changes the overall look of the application: It includes the following styles:

Metal Look and Feel Nimbus Look and Feel CDE/Motif Look and Feel Windows Look and Feel Windows Classic Look and Feel

Metal

Nimbus

CDE/Motif

Windows

Windows Classic

The source code will be mailed on request. Last time I put Source Code on the blog, people didn’t like it much. So this time, its ‘Ask and it shall be mailed’ process. I love Open Source and would always contribute to it. Love Hyderabad too (totally unrelated, I know).

I am currently working on another project with Swetha. I am sure that will be a huge one.

Have Fun Smile.
Enjoy Life while you can Open-mouthed smile.

P.S.: I hope you figured out the irony in the name – ABIS… supposed to relate to Abyss (bottomless pit).

And for people who are interested, here is a road map of Hyderabad with the Bus Routes and also a chart of the bus no’s from which I got the idea of developing this app.

APSRTC Road Map APSRTC Timings

Road Map

Bus Route Chart

Every Problem (even Impossible ones) Have a Solution - Small Story (Must Read)

Many years ago in a small Indian village,

A farmer had the misfortune of owing a large sum of money to a village moneylender.

The Moneylender , who was old and ugly, fancied the farmer's beautiful daughter. So he proposed a bargain.
He said he would forgo the farmer's debt if he could marry his daughter. Both the farmer and his daughter were horrified by the proposal.

So the cunning money-lender suggested that they let Providence decide the matter.

He told them that he would put a black pebble and a white pebble into an empty money bag. Then the girl would have to pick one pebble from the bag.

1) If she picked the black pebble, she would become his wife and her father's debt would be forgiven.
2) If she picked the white pebble she need not marry him and her father's debt would still be forgiven.
3) But if she refused to pick a pebble, her father would be thrown into Jail.


They were standing on a pebble strewn path in the farmer's field. As they talked, the moneylender bent over to pick up two pebbles. As he picked them up, the sharp-eyed girl noticed that he had picked up two black pebbles and put them into the bag.


He then asked the girl to pick a pebble from the bag.

Careful analysis would produce three possibilities:

1. The girl should refuse to take a pebble.
2. The girl should show that there were two black pebbles in the bag and expose the money-lender as a cheat.
3. The girl should pick a black pebble and sacrifice herself in order to save her father from his debt and imprisonment.

Take a moment to ponder over the story. The above story is used with the hope that it will make us 
appreciate the difference between lateral and logical thinking.

The girl's dilemma cannot be solved with traditional logical thinking. Think of the consequences if she chooses the above logical answers.

Well, here is what she did ....

The girl put her hand into the moneybag and drew out a pebble. Without looking at it, she fumbled and let it fall onto the pebble-strewn path where it immediately became lost among all the other pebbles.

"Oh, how clumsy of me," she said. "But never mind, if you look into the bag for the one that is left, you will be able to tell which pebble I picked."

Since the remaining pebble is black, it must be assumed that she had picked the white one. And since the money-lender dared not admit his dishonesty, the girl changed what seemed an impossible situation into an extremely advantageous one.





Courtesy: Shiva. Thanks Buddy :)

Jaw-Dropping Belly-Dance by Sadie

You have to see it to believe it. I watched this video(which a friend sent me) with a pre-conviction that all I was going to get is some Egyptian girl dancing some silly steps to Shakira's 'Hips Don't Lie'. But what I got is something completely different.
Shakira has got some other talents, but when it comes to Belly Dancing, I don't think that she is anywhere near to Sadie. Just watch the first video for an idea of what I am talking about. If you liked Shakira (or even Mumaith Khan from South India), then you sure will adore this pro belly dancer.
 
I know this post is a little off-topic for ECEROCKS, but still, couldn't resist :D
Here is some background info on Sadie from her Bio:
Sadie

Sadie is an International performing artist, instructor and choreographer who is recognized worldwide as one of today's most exciting Belly Dance artists. First seen as a “Rising Star” on BD-TV Vol.II in 2004, Sadie now has dozens of instructional and performance DVDs available, has visited over 25 countires teaching and performing the art of Belly Dance and is one of the most watched bellydancers on youtube with over 10 million hits on just one video clip alone.

Sadie trained in gymnastics and swimming for 14 years as a child and adolescent. She began practicing Belly Dance in her late teens. As a student, Sadie studied with many reputable Middle Eastern dance and music teachers from around the world. Some of the most influential moments in her education include two extended trips to Turkey where she studied and observed the dance and learning to play the doombek (Middle Eastern hand drum) via master percussionist and musician Souhail Kaspar, which impressed a great understanding of the varied Middle Eastern rhythms as well as the relationship between the music and dance.

 

Have Fun :)

Apple’s Future Products - LOL

What with the recent problems (the iPhone 4 Antenna) that Apple’s facing, watching this parody had me rolling on the floor laughing. Have a look at the last two, especially the last one is damn funny.

Steve Jobs with Future Products

 

Courtesy: Shiva :)

The Hindu Newspaper Collection: Archive from Jan 1st,2000-today

I recently found myself very (I mean really very) much interested in reading the Editorial Section of the Hindu Newspaper (Opinion Section). So I tried searching for those pages in the Hindu page, but they only have ported some pages from the old site to the new site (although the new dates are also launched in the old site). I went to their archive page and found a form for searching through their archives.

I found that it was not sufficient for my needs, so I started modifying it and came up with my own version of the Archive Searching mechanism. And I ended up with the code you see below :). Instead of opening the Hindu page of the corresponding page in a new window, I put it up in a popup so that it is easy to maintain and light too.

I designed a blogger Gadget to boot, and added it to ECEROCKS.com. You can now see it the right column (the last one) in the site. Go on, give it a go.

I developed one extra feature of opening a particular date’s Opinion’s page directly along with the pre-existing feature of opening that dates newspaper (I know its lame and useless, but I use it like hell)

The Hindu archives is available from 1st January, 2000 till today on the Hindu’s legacy site at http://www.hindu.com and from 1st June, 2010 onwards in the new website. Please use the archiver given on the right to explore the Hindu’s archives.

LEGACY ARCHIVE (1ST JANUARY 2000 - Today)

The Hindu Archive - Felix

This is how it looks

This is the Javascript to be included along with the HTML Code give below this.
The script below is very easy to understand as you can see. It just checks the values that are selected once a submit button is clicked, then validates over a few basic conditions, and generates a URL, that follows the hindu legacy site’s format.

JAVASCRIPT:

<script javascript="JavaScript">  
<!--
function getHinduOpinionsforDate(){
if( document.archives.YEAR1.options[document.archives.YEAR1.selectedIndex].value == "2000" && document.archives.MONTH1.options[document.archives.MONTH1.selectedIndex].value <= 00)
{
alert("Year 2000 archives are available from January only");
}
else
{

window.open('http://www.hindu.com/'+document.archives.YEAR1.options[document.archives.YEAR1.selectedIndex].value+'/'+document.archives.MONTH1.options[document.archives.MONTH1.selectedIndex].value+'/'+document.archives.DAY1.options[document.archives.DAY1.selectedIndex].value+'/05hdline.htm','theHinduOpinion.blogspot.com','toolbar=0,location=0, directories=0, status=0, menubar=0,scrollbars=1,resizable=1,width=800,height=600,left=0,top=0,url=0') ;
window.status="Going to archives...";
}
}

function getHinduIssueforDate(){
if( document.archives.YEAR2.options[document.archives.YEAR2.selectedIndex].value == "2000" && document.archives.MONTH2.options[document.archives.MONTH2.selectedIndex].value <= 00)
{
alert("Year 2000 archives are available from January only");
}
else
{

window.open('http://www.hindu.com/thehindu/'+document.archives.YEAR2.options[document.archives.YEAR2.selectedIndex].value+'/'+document.archives.MONTH2.options[document.archives.MONTH2.selectedIndex].value+'/'+document.archives.DAY2.options[document.archives.DAY2.selectedIndex].value+'/','theHinduOpinion.blogspot.com','toolbar=0,location=0, directories=0, status=0, menubar=0,scrollbars=1,resizable=1,width=800,height=600,left=0,top=0,url=0') ;
window.status="Going to archives...";
}
}
//-->
</script>





HTML (Generates the required Drop-Downs, Buttons and OnClick functions for Javascript):




<form name="archives" method="POST">
<center>
Select Date to get Opinions Page
<table>
<tr>
<td><select name="MONTH1">
<option value="01" />Jan
<option value="02" />Feb
<option value="03" />Mar
<option value="04" />Apr
<option value="05" />May
<option value="06" />Jun
<option value="07" />Jul
<option value="08" />Aug
<option value="09" />Sep
<option value="10" />Oct
<option value="11" />Nov
<option value="12" />Dec
</select></td>
<td><select name="DAY1">
<option value="01" />01
<option value="02" />02
<option value="03" />03
<option value="04" />04
<option value="05" />05
<option value="06" />06
<option value="07" />07
<option value="08" />08
<option value="09" />09
<option value="10" />10
<option value="11" />11
<option value="12" />12
<option value="13" />13
<option value="14" />14
<option value="15" />15
<option value="16" />16
<option value="17" />17
<option value="18" />18
<option value="19" />19
<option value="20" />20
<option value="21" />21
<option value="22" />22
<option value="23" />23
<option value="24" />24
<option value="25" />25
<option value="26" />26
<option value="27" />27
<option value="28" />28
<option value="29" />29
<option value="30" />30
<option value="31" />31
</select></td>
<td><select name="YEAR1">

<option value="2010" />2010
<option value="2009" />2009
<option value="2008" />2008
<option value="2007" />2007
<option value="2006" />2006
<option value="2005" />2005
<option value="2004" />2004
<option value="2003" />2003
<option value="2002" />2002
<option value="2001" />2001
<option value="2000" />2000 <!--
<option value = '1999'> 1999
<option value = '1998'> 1998
<option value = '1997'> 1997
<option value = '1996'> 1996
<option value = '1995'> 1995-->
</select></td>
</tr>
<tr>
<td colspan="3" align="center"><input name="submit" type="button"
value="Get Hindu Opinion" onclick="getHinduOpinionsforDate()" /></td>
</tr>
</table>
<br />
Select Date to get Issue Page
<table>
<tr>
<td><select name="MONTH2">
<option value="01" />Jan
<option value="02" />Feb
<option value="03" />Mar
<option value="04" />Apr
<option value="05" />May
<option value="06" />Jun
<option value="07" />Jul
<option value="08" />Aug
<option value="09" />Sep
<option value="10" />Oct
<option value="11" />Nov
<option value="12" />Dec
</select></td>
<td><select name="DAY2">
<option value="01" />01
<option value="02" />02
<option value="03" />03
<option value="04" />04
<option value="05" />05
<option value="06" />06
<option value="07" />07
<option value="08" />08
<option value="09" />09
<option value="10" />10
<option value="11" />11
<option value="12" />12
<option value="13" />13
<option value="14" />14
<option value="15" />15
<option value="16" />16
<option value="17" />17
<option value="18" />18
<option value="19" />19
<option value="20" />20
<option value="21" />21
<option value="22" />22
<option value="23" />23
<option value="24" />24
<option value="25" />25
<option value="26" />26
<option value="27" />27
<option value="28" />28
<option value="29" />29
<option value="30" />30
<option value="31" />31
</select></td>
<td><select name="YEAR2">

<option value="2010" />2010
<option value="2009" />2009
<option value="2008" />2008
<option value="2007" />2007
<option value="2006" />2006
<option value="2005" />2005
<option value="2004" />2004
<option value="2003" />2003
<option value="2002" />2002
<option value="2001" />2001
<option value="2000" />2000 <!--
<option value = '1999'> 1999
<option value = '1998'> 1998
<option value = '1997'> 1997
<option value = '1996'> 1996
<option value = '1995'> 1995-->
</select></td>
</tr>
<tr>
<td colspan="3" align="center"><input name="submit" type="button"
value="Get Hindu Issue" onclick="getHinduIssueforDate()" /></td>
</tr>
</table>
</center>
</form>





P.S.: Just check out the new blog I started - http://thehinduopinion.blogspot.com/, with the aim of creating an organized Opinion section of the Hindu Newspaper. Updated Daily.

GMailer: A Small yet Powerful Java App to send Email using GMail

Here I am after a long break. I was a ‘LITTLE’ busy with my work at Conseco. And thanks to the trainers there, I was able to explore the unending complexities of Java. Mind the word - ‘explore’ not ‘learn’. I’m as ignorant of Java as I was before my training. And folks, I am back with a bang. I’ve been trying to develop an Anonymous Mailing Application for the last few weeks, but ended up with something completely different. GMAIL. 
GMailerThanks to Mr. Aleem Basha for introducing me to the Java mailing api.

Without further delay – let me present to you: GMAILER :
Download Gmailer HERE or HERE or HERE or HERE or HERE or HERE. Its only 513 KB
Double click the downloaded jar file to run it. Below is the screenshot. It runs on all OS’s (having jre installed) be it windows, linux, solaris, mac etc. Tested it on Windows XP, Vista and Windows 7.

GMailer - Felix

Type in your Gmail ID and Password, Enter the mail id of your recipient, Attach a File and then click on ‘Send Mail’ to Send the mail to the specified Email Address.
There is no need to open a browser, login to Gmail, Click on Compose Mail to send a mail.
All you have to do is use this small (only 513 kb), yet powerful little tyke of an app to do your job. Your ID and Password are not stored anywhere – once you exit the application everything is cleared off.

I like sharing things. I like to give as much as I like to take from the Internet. So I am keeping the complete source code of this application here – OPEN SOURCE:

Source Code for Gmailer:

/*
//GMailer - Felix Source Code
//Project Name: GMailer
//Developed by: Ashok
//Developed for: AMO
//Home Page: http://www.ecerocks.com/
//Project Completed: 02 May, 2010
//IDE USED: None
//Executable JAR: Eclipse IDE
//External JAR's: mail.jar, activation.jar
//Status: Completed and Deployed Successfully
*/
package FelixMail;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.regex.*;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;
import javax.activation.FileDataSource;
import javax.activation.DataHandler;

public class FelixMailAttachment extends JFrame implements ActionListener, WindowListener, FocusListener
{
private static final long serialVersionUID = 1L;
String d_email;
String d_password;
String filename=null;

JLabel label_to,label_subject,label_body,label_username,label_password,label_gmailcom,label_smtp,label_port,label_felix,label_info, label_head, label_attachment, label_attachmentName;
JTextField t_to,t_subject,t_username,t_smtp,t_port;
JPasswordField t_password;
JTextArea t_body;
JButton btn_send,btn_quit,btn_reset,btn_defaults, btn_attach;
JScrollPane scrollPane;

public FelixMailAttachment()
{
label_head=new JLabel("GMAILER - FELIX");
label_head.setForeground(Color.blue);
label_head.setFont(new Font("Serif", Font.BOLD, 15));
label_to=new JLabel(" TO : ");
label_subject=new JLabel(" SUBJECT : ");
label_attachment=new JLabel(" ATTACH FILES : ");
label_attachmentName=new JLabel("");
label_body=new JLabel(" E-Mail BODY : ");
label_username=new JLabel(" GMAIL USERNAME : ");
label_password=new JLabel(" PASSWORD : ");
label_gmailcom=new JLabel("@gmail.com");
label_smtp=new JLabel("SMTP Address : ");
label_port=new JLabel(" PORT NUMBER : ");
label_felix=new JLabel("© Ashok Felix (www.ecerocks.com): AMO");
label_info=new JLabel(" Enter Gmail Username,Password,To,Subject and Body - Click Send ");
btn_send=new JButton(" SEND MAIL");
btn_quit=new JButton(" QUIT ");
btn_reset=new JButton(" RESET ");
btn_defaults=new JButton(" DEFAULTS ");
btn_attach=new JButton("ATTACH FILE");

t_to=new JTextField(40);
t_to.setText("DestinationMail@dummmyMail.com");
t_subject=new JTextField(50);
t_subject.setText("Hi, there...");
t_username=new JTextField(20);
t_username.setText("www.ecerocks.com");
t_body=new JTextArea(5,20);
t_body.setText("Write the content of your mail here....");
t_password=new JPasswordField(20);
t_password.setEchoChar('$');
t_password.setText("011235813");
t_port=new JTextField(5);
t_port.setText("465");
t_smtp=new JTextField(20);
t_smtp.setText("smtp.gmail.com");
scrollPane = new JScrollPane(t_body);


setLayout(null);

label_head.setBounds(180,5,300,20);
label_username.setBounds(70,30,120,20);
label_password.setBounds(70,60,120,20);
t_username.setBounds(200,30,120,20);
label_gmailcom.setBounds(325,30,120,20);
t_password.setBounds(200,60,120,20);

label_to.setBounds(87,100,40,20);
t_to.setBounds(130,100,300,20);

label_subject.setBounds(50,130,100,20);
t_subject.setBounds(130,130,300,20);

label_attachment.setBounds(50,160,100,20);
label_attachmentName.setBounds(150,160,300,20);
btn_attach.setBounds(330,160,110,20);

label_body.setBounds(38,185,100,50);
scrollPane.setBounds(130,205,340,300);

btn_send.setBounds(40,515,100,30);
btn_reset.setBounds(150,515,100,30);
btn_defaults.setBounds(260,515,100,30);
btn_quit.setBounds(370,515,100,30);

label_smtp.setBounds(40,560,100,20);
t_smtp.setBounds(137,560,150,20);
label_port.setBounds(300,560,100,20);
t_port.setBounds(400,560,50,20);

label_felix.setBounds(150,600,300,20);
label_info.setBounds(10,620,500,20);

add(label_username);
add(label_password);
add(t_username);
add(t_password);
add(label_gmailcom);
add(label_to);
add(t_to);
add(label_subject);
add(t_subject);
add(label_attachment);
add(label_attachmentName);
add(btn_attach);
add(label_body);
add(scrollPane);
add(btn_send);
add(btn_quit);
add(btn_reset);
add(btn_defaults);
add(label_smtp);
add(t_smtp);
add(label_port);
add(t_port);
add(label_felix);
add(label_info);
add(label_head);


btn_send.addActionListener(this);
btn_quit.addActionListener(this);
btn_reset.addActionListener(this);
btn_defaults.addActionListener(this);
btn_attach.addActionListener(this);
this.addWindowListener(this);
t_to.addFocusListener(this);
t_subject.addFocusListener(this);
t_username.addFocusListener(this);
t_smtp.addFocusListener(this);
t_port.addFocusListener(this);
t_password.addFocusListener(this);
t_body.addFocusListener(this);


setSize(500,670);
setVisible(true);
setResizable(false);
setTitle("Gmailer - Felix");
this.setDefaultCloseOperation ( JFrame.DO_NOTHING_ON_CLOSE );

}

public void actionPerformed(ActionEvent ae){
if(ae.getSource()==btn_send){
Cursor hourglasscursor = new Cursor(Cursor.WAIT_CURSOR);
setCursor(hourglasscursor);
label_info.setText("Sending Mail. Please wait for a FEW Moments");
//System.out.println("Send Button Clicked");
d_email=t_username.getText()+label_gmailcom.getText();
char[] pwd=t_password.getPassword();
d_password=new String(pwd);
String m_to=t_to.getText();
String m_subject=t_subject.getText();
String m_text=t_body.getText();
String d_host=t_smtp.getText();
String d_port=t_port.getText();
//Email Validation Start
Pattern ptrn = Pattern.compile(".+@.+\\.[a-z]+");
Matcher m = ptrn.matcher(m_to);
boolean validEmail = m.matches();
System.out.println(validEmail);
//Email Validation End

if(m_to.equals("") || m_to.equals("DestinationMail@dummmyMail.com")){
JOptionPane.showMessageDialog(this,"Enter Valid Recipient E-Mail Address");
t_to.requestFocus();
}
else if(!validEmail){
JOptionPane.showMessageDialog(this,"Invalid Email. Enter Correct E-Mail Format");
t_to.requestFocus();
}
else if(m_subject.equals("")){
JOptionPane.showMessageDialog(this,"Enter Subject for E-Mail");
t_subject.requestFocus();
}
else if(d_host.equals("")){
JOptionPane.showMessageDialog(this,"Enter Valid SMTP Address (smtp.gmail.com)");
t_smtp.requestFocus();
}
else if(d_port.equals("")){
JOptionPane.showMessageDialog(this,"Enter Valid Port Number (465)");
t_port.requestFocus();
}
else if(m_text.equals("")){
JOptionPane.showMessageDialog(this,"Enter Body Content For Email");
t_body.requestFocus();
}
else{
//System.out.println(d_email+" "+d_password+" "+m_to+" "+m_subject+" "+m_text+" "+d_host+" "+d_port);
//Mail Sending Code Start
Properties props = new Properties();
props.put("mail.smtp.user", d_email);
props.put("mail.smtp.host", d_host);
props.put("mail.smtp.port", d_port);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.auth", "true");
//props.put("mail.smtp.debug", "true");
props.put("mail.smtp.socketFactory.port", d_port);
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");

try
{
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getInstance(props, auth);
//session.setDebug(true);

MimeMessage msg = new MimeMessage(session);
//msg.setText(m_text);

// create and fill the first message part
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(m_text);

// create the Multipart and add its parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);


//File Attach Conditional Code
if(filename!=null){
// create the second message part
MimeBodyPart mbp2 = new MimeBodyPart();

// attach the file to the message
FileDataSource fds = new FileDataSource(filename);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());

mp.addBodyPart(mbp2);
}
///

// add the Multipart to the message
msg.setContent(mp);

// set the Date: header
msg.setSentDate(new Date());


msg.setSubject(m_subject);
//msg.setFrom(new InternetAddress("abc@gmail.com"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m_to));
Transport.send(msg);
System.out.println("success");
label_info.setText("E-Mail Sent Successfully");
Cursor normalcursor = new Cursor(Cursor.DEFAULT_CURSOR);
setCursor(normalcursor);
JOptionPane.showMessageDialog(this,"Message Sent Successfully to "+m_to);
}
catch (Exception mex)
{
JOptionPane.showMessageDialog(this,"Error Sending E-Mail: \n"+mex);
mex.printStackTrace();
}
//Mail Sending Code End
}//Validation Conditions
}//Send Button End
else if(ae.getSource()==btn_quit){
System.out.println("Quit Button Clicked");
label_info.setText("Wanna Quit? Confirm...");
int confirm=JOptionPane.showConfirmDialog(this,"Do you want to Quit?");
if(confirm==0){
System.exit( 0 );
}
if(confirm==1){
label_info.setText(" Wow, you decided to stick around then. Enjoy :) ");
}
}
else if(ae.getSource()==btn_reset){
label_info.setText("Reset");
//System.out.println("Reset Button Clicked");
t_to.setText("");
t_subject.setText("");
t_body.setText("");
t_smtp.setText("smtp.gmail.com");
t_port.setText("465");
label_info.setText("All Fields Reset");
JOptionPane.showMessageDialog(this,"All Fields Reset");
}
else if(ae.getSource()==btn_defaults){
//System.out.println("Default Button Clicked");
t_username.setText("www.ecerocks.com");
t_password.setText("011235813");
t_smtp.setText("smtp.gmail.com");
t_port.setText("465");
label_info.setText("Default Values Loaded");
JOptionPane.showMessageDialog(this,"Default Values Loaded");

}
else if(ae.getSource()==btn_attach){
//System.out.println("Default Button Clicked");
JFileChooser chooser=new JFileChooser();
int returnVal=chooser.showOpenDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
label_attachmentName.setText(chooser.getSelectedFile().getName());
File selectedFile = chooser.getSelectedFile();
this.filename=selectedFile.getPath();
//System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName());
JOptionPane.showMessageDialog(this,"File " +this.filename+" Attached Successfully");
}
}
}

private class SMTPAuthenticator extends javax.mail.Authenticator{
public javax.mail.PasswordAuthentication getPasswordAuthentication(){
return new javax.mail.PasswordAuthentication(d_email, d_password);
}
}

//WindowListener Interface Methods Start
public void windowActivated(WindowEvent e){ }
public void windowClosed(WindowEvent e){}
public void windowClosing(WindowEvent e){
//System.out.println("Window Closing");
int confirm=JOptionPane.showConfirmDialog(this,"Do you want to Quit?");
if(confirm==0){
System.exit( 0 );
}
if(confirm==1){
label_info.setText(" Wow, you decided to stick around then. Enjoy :) ");
}
}
public void windowDeactivated(WindowEvent e){
//label_info.setText(" Got Some Other Work? Or got to copy paste something else here?");
}
public void windowDeiconified(WindowEvent e){
label_info.setText(" Window is Deiconified. I'm not sure what that means.. :) ");
}
public void windowIconified(WindowEvent e){
label_info.setText(" Window Iconified. Don't worry, I don't know what that means :) ");
}
public void windowOpened(WindowEvent e){}
//WindowListener Interface Methods End


//FocusListener Interface Methods Start
public void focusGained(FocusEvent e){
if((Component)t_username==e.getComponent()){
label_info.setText(" Enter Your Gmail Username ");
}
else if((Component)t_password==e.getComponent()){
label_info.setText(" Enter Password - Don't worry, its not stored anywhere ");
}
else if((Component)t_to==e.getComponent()){
label_info.setText(" Enter the E-mail address of the person to whom you want to send this mail ");
}
else if((Component)t_subject==e.getComponent()){
label_info.setText(" Enter a brief Subject about the purpose of this E-Mail ");
}
else if((Component)t_body==e.getComponent()){
label_info.setText(" Enter Content for this E-Mail. And don't be a skinflint");
}
else if((Component)t_smtp==e.getComponent()){
label_info.setText(" Enter a Valid SMTP address - Most problems arise from a wrong SMTP ");
}
else if((Component)t_port==e.getComponent()){
label_info.setText(" Enter a Port Number for the respective SMTP (default: 25) ");
}
if((Component)t_body!=e.getComponent()){
JTextField textField = (JTextField)e.getComponent();
textField.selectAll();
}
else if((Component)t_body==e.getComponent()){
JTextArea textArea = (JTextArea)e.getComponent();
textArea.selectAll();
}
}
public void focusLost(FocusEvent e){}

//FocusListener Interface Methods End

public static void main(String a[]){
new FelixMailAttachment();
}
}






Took me some time to develop it, but I think it turned out just fine.



This application is useful for three kinds of people:
1. People who don’t know how to use Gmail
2. People who are too lazy to open the browser, login, compose, etc. from Gmail.
3. Students who are interested to learn Java (If anybody needs clarifications regarding the code, then please leave comments)



Here is the Google Project Page for GMailer



I would like to say much much more about this little app, but I know you’d be bored. So try it and let me know how you feel about it…