Intranet Mailing System: Project Report On
Intranet Mailing System: Project Report On
Submitted by
VIGNESHWARAN. R.
Miss. R. Kalaiyarasi
1|Page
CSC COMPUTER EDUCATION
SIMMAKKAL
MADURAI – 625001.
CERTIFICATE
This is to certify that this project entitled “Intranet Mailing System” using Java is
the Bonafide Record of work done by VIGNESHWARAN. R. in partial fulfillment of
the requirements for the award of DIPLOMA IN J2EE PROGRAMMING.
BRANCH MANAGER
PLACE: MADURAI
DATE:
2|Page
ACKNOWLEDGEMENT
“I have to Thank God Almighty For all his benevolence”. I extend my deep
sense of gratitude to all people who have guided, inspired and motivated me
during this project.
I express my sincere praise and thanks to Lord Almighty for his blessings
showered on me throughout my life, especially for this project work.
Finally, I thank all of them who directly and indirectly helped in bringing this
project as a successful one and extend my thanks to all my CSC COMPUTER
EDUCATION staffs and friends, whose timely help, while working on project.
3|Page
Declaration
Submitted by
VIGNESHWARAN. R.
4|Page
INDEX
S.NO CONTENT
1. SYNOPSIS
2. SYSTEM CONFIGURATION
3. JAVA
4. SWING
5. MS-ACCESS
6. DATA STRUCTURES
8. SOURCE CODE
9. SCREEN LAYOUTS
10. CONCLUSION
11. BIBLIOGRAPHY
5|Page
SYNOPSIS
Present System:
Nowadays the organizations are growing fast and are increasing in size also.
So the organizations are divided into departments. In the fast growing world the
information is needed as fast as possible. This can be accomplished by passing the
information quickly. Quick passing of mails is not possible in load manual systems
because in manual systems the mails are passed through persons from one
department to another. It takes mush time and risk also. This leads the
inconsistency of information. So we need a system which is both quick and
accurate. This can be achieved by this project.
The main aim of this project is to send the mails spontaneously without
requiring the parties be available at the same instant. It is much cheaper than the
manual system.
The main advantage of the Intra mail system is its security feature allowing
only registered users to access the system and preventing any hackers,
unauthorized users. Another interesting feature is the notifying feature which
displays a popup alert to notify the users of new messages for 5seconds before
disappearing. It also has an address book and newsreader.
6|Page
Modules Involved:
Registration – In this module a new user can register his / her details for accessing
this product. Once they registered or if they already have an id and password,
they can enter through the login portal and can access the application. New Users
details stored in a database and the existing details obtained from the same for
checking at the time of login. The user details are automatically added to the
admin’s address book during the registration itself.
Menu Window – This module welcomes the user and provides the options for
accessing other modules. This module displays a popup at the lower right corner
of the screen if there are any new messages for the user waiting to be read. Once
the work is finished, the user can choose to either exit or just logout from the
application for the other users to use, in case.
Mail Editor – This is the most primary module of the application. It is used to send
and receive mails. It has a separate window for inbox and composing window. In
the inbox pane, the list of received messages is displayed in a list and the user can
view the full message, subject and time of message by clicking the sender name in
the list. The user can also reply to the sender which automatically fills in the
subject and recipient address in the composing window. In the composing
window, the user can view his address book to refer the recipient’s mail address.
News Editor – This module is only accessible to the admin. It provides the options
for the admin to add news and events common to all the End Users.
News Reader – This module is available to all the users except the admin. It
displays the news and upcoming events common to all other End Users sent by
the admin.
Address Book – For easy user reference, the other’s personal details and email
addresses can be stored in a database using this application. Whenever user
need, he / she can retrieve the details from the address book. The EndUser can
only view the addresses he added in the address book where admin can view all.
7|Page
SYSTEM CONFIGURATION
Hardware specification:
Processor : Pentium IV
RAM : 256MB
Keyboard : 104keys
Software specification:
Front end : Java Swing
8|Page
JAVA
Introduction
Java is a programming language originally developed by James Gosling at
Sun Microsystems and released in 1995 as a core component of Sun
Microsystems' Java platform. The language derives much of its syntax from C and
C++ but has a simpler object model and fewer low-level facilities. Java
applications are typically compiled to bytecode (class file) that can run on any
Java Virtual Machine (JVM) regardless of computer architecture.
History
James Gosling initiated the Java language project in June 1991 for use in
one of his many set-top box projects. Gosling aimed to implement a virtual
machine and a language that had a familiar C/C++ style of notation. Sun released
the first public implementation as Java 1.0 in 1995. It promised "Write Once, Run
Anywhere" (WORA), providing no-cost run-times on popular platforms. Fairly
secure and featuring configurable security, it allowed network- and file-access
restrictions. Major web browsers soon incorporated the ability to run Java applets
within web pages, and Java quickly became popular.
Principles
There were five primary goals in the creation of the Java language:
9|Page
Java Platform
One characteristic of Java is portability, which means that computer
programs written in the Java language must run similarly on any supported
hardware/operating-system platform. This is achieved by compiling the Java
language code to an intermediate representation called Java bytecode, instead of
directly to platform-specific machine code. Java bytecode instructions are
analogous to machine code, but are intended to be interpreted by a virtual
machine (VM) written specifically for the host hardware. End-users commonly use
a Java Runtime Environment (JRE) installed on their own machine for standalone
Java applications, or in a Web browser for Java applets.
Syntax
The syntax of Java is largely derived from C++. Unlike C++, which combines
the syntax for structured, generic, and object-oriented programming, Java was
built almost exclusively as an object oriented language. All code is written inside a
class and everything is an object, with the exception of the intrinsic data types
(ordinal and real numbers, boolean values, and characters), which are not classes
for performance reasons. Java uses the same commenting methods as C++. There
are two different styles of comment: a single line style marked with two forward
slashes, and a multiple line style opened with a forward slash asterisk (/*) and
closed with an asterisk forward slash (*/).
10 | P a g e
SWING
Introduction
Swing is a widget toolkit for Java. It is part of Sun Microsystems' Java
Foundation Classes (JFC) — an API for providing a graphical user interface (GUI)
for Java programs.
History
The Internet Foundation Classes (IFC) were a graphics library for Java
originally developed by Netscape Communications Corporation and first released
on December 16, 1996. On April 2, 1997, Sun Microsystems and Netscape
Communications Corporation announced their intention to incorporate IFC with
other technologies to form the Java Foundation Classes.
Swing introduced a mechanism that allowed the look and feel of every
component in an application to be altered without making substantial changes to
the application code. The introduction of support for a pluggable look and feel
allows Swing components to emulate the appearance of native components while
still retaining the benefits of platform independence. This feature also makes it
easy to make an application written in Swing look very different from native
programs if desired.
11 | P a g e
Architecture
Swing is a platform-independent, Model-View-Controller GUI framework for Java.
It follows a single-threaded programming model, and possesses the following
traits:
Foundations
Platform independence
Swing is platform independent both in terms of its expression (Java) and its
implementation (non-native universal rendering of widgets).
Extensibility
Component-oriented
Customizable
12 | P a g e
of a standard set of elements, such as a "border", "inset", decorations, etc.
Typically, users will programmatically customize a standard Swing component
(such as a JTable) by assigning specific Borders, Colors, Backgrounds, opacities,
etc., as the properties of that component. The core component will then use
these property (settings) to determine the appropriate renderers to use in
painting its various aspects. However, it is also completely possible to create
unique GUI controls with highly customized visual representation.
Configurable
Lightweight UI
Swing's configurability is a result of a choice not to use the native host OS's
GUI controls for displaying itself. Swing "paints" its controls programmatically
through the use of Java 2D APIs, rather than calling into a native user interface
toolkit. Thus, a Swing component does not have a corresponding native OS GUI
component, and is free to render itself in any way that is possible with the
underlying graphics APIs.
Swing allows one to specialize the look and feel of widgets, by modifying
the default (via runtime parameters), deriving from an existing one, by creating
one from scratch, or, beginning with J2SE 5.0, by using the skinnable synth Look
and Feel, which is configured with an XML property file. The look and feel can be
changed at runtime, and early demonstrations of Swing frequently provided a
way to do this.
13 | P a g e
MS – ACCESS
Introduction
Microsoft Office Access, previously known as Microsoft Access, is a
relational database management system from Microsoft that combines the
relational Microsoft Jet Database Engine with a graphical user interface and
software development tools. It is a member of the Microsoft Office suite of
applications and is included in the Professional and higher versions for Windows
and also sold separately.
Access stores data in its own format based on the Access Jet Database
Engine. It can also import or link directly to data stored in other Access databases,
Excel, SharePoint lists, text, XML, Outlook, HTML, dBase, Paradox, Lotus 1-2-3, or
any ODBC-compliant data container including Microsoft SQL Server, Oracle,
MySQL and PostgreSQL. Software developers and data architects can use it to
develop application software and non-programmer "power users" can use it to
build simple applications.
Features
Users can create tables, queries, forms and reports, and connect them
together with macros. The original concept of Access was for end users to be able
to “access” data from any source. Other uses include: the import and export of
data to many formats including Excel, Outlook, ASCII, dBase, Paradox, FoxPro, SQL
Server, Oracle, ODBC, etc. It also has the ability to link to data in its existing
location and use it for viewing, querying, editing, and reporting. This allows the
existing data to change and the Access platform to always use the latest data. It
can perform heterogeneous joins between data sets stored across different
platforms. Access is often used by people downloading data from enterprise level
databases for manipulation, analysis, and reporting locally.
14 | P a g e
There is also the Jet Database format (MDB or ACCDB in Access 2007) which
can contain the application and data in one file. This makes it very convenient to
distribute the entire application to another user, who can run it in disconnected
environments.
The desktop editions of Microsoft SQL Server can be used with Access as an
alternative to the Jet Database Engine. This support started with MSDE (Microsoft
SQL Server Desktop Engine), a scaled down version of Microsoft SQL Server 2000,
and continues with the SQL Server Express versions of SQL Server 2005 and 2008.
Protection
Microsoft Access offers several ways to secure the application while
allowing users to remain productive.
The most basic is a database password. Once entered, the user has full
control of all the database objects. This is a relatively weak form of protection
which can be easily cracked.
15 | P a g e
DATA STRUCTURES
TABLE NAME: registration
16 | P a g e
TABLE NAME: news_details
17 | P a g e
SOURCE
CODE
18 | P a g e
Portal.java:
/* To display the Portal Screen for User Name and Password Checking */
package Classes;
pw = new Label("Password");
buildConstraints(gbc, 0, 2, 1, 1, 0, 12);
gbc.fill = GridBagConstraints.NONE;
gbl.setConstraints(pw, gbc);
add(pw);
19 | P a g e
pword = new JPasswordField(10);
buildConstraints(gbc, 1, 2, 2, 1, 0, 0);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbl.setConstraints(pword, gbc);
add(pword);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we)
{
setVisible(false);
System.exit(0);
}
} );
}
20 | P a g e
String unm,pwd;
unm = uname.getText();
pwd = pword.getText();
uname.setText("");
pword.setText("");
int res = d.checkUser(unm,pwd);
if (res == 1)
{
setVisible(false);
MenuWin i= new MenuWin(unm);
i.setLocation(0,0);
i.setSize(800,600);
i.setVisible(true);
}
else if (res == 0)
{
Dialog db = new Dialog(this,"Error",true);
db.setLayout(new BorderLayout());
db.setSize(100,100);
}
}
class T implements ActionListener {
Dialog db;
public T(Dialog db){
this.db = db;
}
public void actionPerformed(ActionEvent ae) {
db.dispose();
}
}
21 | P a g e
gbc.gridy = y; // start cell in a column
gbc.gridwidth = w; // how many column does the control occupy in the row
gbc.gridheight = h; // how many column does the control occupy in the column
gbc.weightx = wx; // relative horizontal size
gbc.weighty = wy; // relative vertical size
}
}
Registration.java
/**
* To Register and Add new users and their details in addressbook
*/
package Classes;
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.*;
setLayout(null);
setForeground(Color.black);
uid = new JLabel("User Id");
uid.setBounds(250,100,100,25);
add(uid);
22 | P a g e
add(uname);
sex=new JLabel("Sex");
sex.setBounds(250,280,100,25);
add(sex);
cg = new ButtonGroup();
c1 = new JRadioButton("Male",true);
c2 = new JRadioButton("Female",false);
cg.add(c1);
cg.add(c2);
add(c1);
c1.setBounds(350,280,100,25);
add(c2);
c2.setBounds(450,280,100,25);
23 | P a g e
dt=new JComboBox();
for (int i = 1; i < 32; i++) {
dt.addItem(Integer.toString(i));
}
dt.setBounds(350,310,50,20);
mn=new JComboBox();
for (int i = 1; i < 13; i++) {
mn.addItem(Integer.toString(i));
}
mn.setBounds(400,310,50,20);
yr=new JComboBox();
for (int i = 1975; i < 2000; i++) {
yr.addItem(Integer.toString(i));
}
yr.setBounds(450,310,60,20);
add(dt);
add(mn);
add(yr);
24 | P a g e
add(mail1);
connectDB();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we)
{
setVisible(false);
Portal l = new Portal();
//l.setSize(640,480);
l.setResizable(false);
l.pack();
l.setLocationByPlatform(true);
l.setVisible(true);
}
} );
25 | P a g e
que = hint1.getText();
ans = ans1.getText();
if (c1.isSelected() == true)
sex = 'M';
else if (c2.isSelected() == true)
sex = 'F';
d = Integer.parseInt(dt.getItemAt(dt.getSelectedIndex())+"");
m = Integer.parseInt(mn.getItemAt(mn.getSelectedIndex())+"");
y = Integer.parseInt(yr.getItemAt(yr.getSelectedIndex())+"");
addr = address.getText();
cy = city1.getText();
ph = phone1.getText();
int i;
for (i=0;i<ph.length();i++) {
if (ph.charAt(i) < 48 || ph.charAt(i) > 57)
pf = false;
}
em = mail1.getText();
for (i=0;i<em.length();i++) {
if (em.charAt(i) == '@')
fs1++;
if (em.charAt(i) == '.')
fs2++;
}
if (fs1 != 1 || fs2 !=1)
ef = false;
if (pwf == true && pf == true && ef == true && ucf == true)
{
try
{
st = con.prepareStatement("insert into registration values
(?,?,?,?,?,?,?,?,?,?,?)");
st.setString(1,uid);
st.setString(2,unm);
st.setString(3,pwd);
st.setString(4,que);
st.setString(5,ans);
st.setString(6,String.valueOf(sex));
st.setString(7,d + "/" + m + "/" + y);
st.setString(8,addr);
st.setString(9,cy);
st.setString(10,ph);
st.setString(11,em);
st.execute();
st = con.prepareStatement("insert into addr_book values (?,?,?,?,?,?)");
st.setString(1,unm);
st.setString(2,addr);
st.setString(3,cy);
st.setString(4,em);
st.setString(5,ph);
st.setString(6, "admin");
st.execute();
st = con.prepareStatement("insert into notif values (?,?)");
st.setString(1,unm);
st.setString(2,"yes");
st.execute();
26 | P a g e
//Registration.showErrMes("Inserted");
tf = new Frame("Ack");
tf.setBackground(Color.BLACK);
tf.setSize(100,100);
tf.setLocation(300,250);
JLabel l = new JLabel("Record Inserted", JLabel.CENTER);
l.setForeground(Color.green);
tf.add(l);
tf.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
tf.setVisible(false);
setVisible(false);
Portal l = new Portal();
//l.setSize(640,480);
l.setResizable(false);
l.pack();
l.setLocationByPlatform(true);
l.setVisible(true);
l.uname.setText(uid);
l.pword.setText("");
}
});
tf.setVisible(true);
} catch(Exception e) {
Registration.showErrMes(e + "");
}
} else if (pwf == false && pf == true && ef == true) {
showErrMes("Incorrect Password");
} else if (ef == false && pwf == true && pf == true) {
showErrMes("Invalid Email Id");
} else if (pf == false && pwf == true && ef == true) {
showErrMes("Incorrect Phone Number");
} else if (ucf == false) {
showErrMes("Duplicate User! Try with Other Names");
} else {
showErrMes("Error in Inputs");
}
}
else if(ae.getSource()==back)
{
setVisible(false);
Portal l = new Portal();
//l.setSize(640,480);
l.setResizable(false);
l.pack();
l.setLocationByPlatform(true);
l.setVisible(true);
}
}
27 | P a g e
f1.add(l,BorderLayout.NORTH);
f1.add(okay,BorderLayout.SOUTH);
f1.setSize(300,100);
f1.setLocation(225,250);
f1.setVisible(true);
f1.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
f1.setVisible(false);
}
} );
}
public static void showErrMes(String msg) {
showErrMes("Info:",msg);
}
DBase.java
/**
* To Verify UserId and Password
*/
package Classes;
import java.sql.*;
28 | P a g e
Registration.showErrMes("Database Connectivity Error"+e);
}
}
public String getUserId(String emailid) {
try {
st = con.createStatement();
rs = st.executeQuery("select * from registration");
while (rs.next()) {
if (rs.getString(11).equals(emailid))
return rs.getString(1);
}
} catch(Exception e) {}
return null;
}
public int checkUser(String un, String pw) {
try {
st = con.createStatement();
rs = st.executeQuery("select * from registration");
while (rs.next()) {
if (rs.getString(1).equals(un) && rs.getString(3).equals(pw))
return 1;
}
return 0;
} catch(Exception e) {
Registration.showErrMes("Record Set Accessing Error"+e);
}
return 0;
}
MenuWin.java
/* User Entry - Registered User's Portal */
package Classes;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
29 | P a g e
class MenuWin extends JFrame implements ActionListener, Runnable
{
Connection con;
Statement st;
String unm,pwd;
JButton mail,abook,lout,nedt;
JButton com,exit;
JLabel lblTitle,welcome;
Thread t;
public MenuWin(String un)
{
unm = un;
setTitle("Main Menus");
setLayout(null);
if(unm.equals("admin"))
nedt = new JButton("News Editor");
else
nedt = new JButton("News Viewer");
nedt.setBounds(330,220,120,25);
nedt.addActionListener(this);
add(nedt);
exit=new JButton("Exit");
exit.setBounds(100,420,100,25);
exit.addActionListener(this);
add(exit);
30 | P a g e
addWindowListener(new W());
t = new Thread(this);
t.start();
// try {
// notif();
// } catch (InterruptedException ex) {}
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==mail)
{
setVisible(false);
MailEditor e= new MailEditor(unm);
e.setLocation(0,0);
e.setSize(800,600);
e.setVisible(true);
}
else if (ae.getSource() == nedt)
{
setVisible(false);
if (unm.equals("admin")) {
Editor e = new Editor(unm);
e.setLocation(0,0);
e.setSize(800,600);
e.setVisible(true);
} else {
NewsUser ne = new NewsUser(unm);
ne.setLocation(0,0);
ne.setSize(800,600);
ne.setVisible(true);
}
}
else if(ae.getSource()==abook)
{
setVisible(false);
AddBook a= new AddBook(unm);
a.setLocation(0,0);
a.setSize(800,600);
a.setVisible(true);
}
else if(ae.getSource()==lout) {
setVisible(false);
Portal l = new Portal();
l.setResizable(false);
l.pack();
l.setLocationByPlatform(true);
l.setVisible(true);
}
else if(ae.getSource()==exit)
{
System.exit(0);
}
31 | P a g e
}
Notif.java
package Classes;
import java.sql.*;
public Notif() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:dsn");
} catch(Exception e) {
Registration.showErrMes("Database Connectivity Error"+e);
32 | P a g e
}
}
boolean checkedMail(String unm) {
try {
st = con.createStatement();
rs = st.executeQuery("select * from notif");
while (rs.next()) {
if (rs.getString(1).equals(unm) && rs.getString(2).equals("no"))
return false;
}
return true;
} catch(Exception e) {}
return true;
}
}
}
MailEditor.java
package Classes;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
33 | P a g e
String unm,email;
String subjects[],msges[],dates[];
JButton back,cmdSend,cmdClear,showAddr;
Panel panTop,panBot,panTop1,panCom,panInb;
Font bold = new Font("Arial",Font.BOLD,13);
List l = new List(10);
int mailcount=0;
public MailEditor(String un)
{
unm = un;
setTitle("Mail Editor Screen");
setLayout(new BorderLayout());
inbox=new JButton("Inbox");
// inbox.setBounds(30,150,100,25);
inbox.addActionListener(this);
panTop1.add(inbox);
back=new JButton("Back");
// back.setBounds(100,500,100,25);
back.addActionListener(this);
panTop1.add(back);
panTop.add("North",edt);
panTop.add("South",panTop1);
addWindowListener(new W());
//addInPane();
//addOutPane();
connectDB();
// Main Panels
34 | P a g e
add("North",panTop);
add("Center",panBot);
try{
st = con.createStatement();
rs = st.executeQuery("select * from registration");
while(rs.next())
if(rs.getString(1).equals(unm))
email = rs.getString(11);
} catch(Exception e){
Registration.showErrMes("Error in receiving mail id");
}
// Panel Inbox
void addInPane() {
panInb = new Panel();
showMsg = new TextArea("Select a Message",100,100);
showMsg.setEditable(false);
mailcount=0;
l.removeAll();
l.addItemListener(this);
panInb.setLayout(new BorderLayout());
try {
st = con.createStatement();
rs = st.executeQuery("select * from mail_details");
while (rs.next())
if(rs.getString(2).equals(email))
mailcount++;
subjects = new String[mailcount];
msges = new String[mailcount];
dates = new String[mailcount];
rs = st.executeQuery("select * from mail_details");
int i=0;
while(rs.next())
if(rs.getString(2).equals(email)) {
l.add(rs.getString(1));
dates[i] = rs.getString(3);
subjects[i] = rs.getString(4);
msges[i] = rs.getString(5);
i++;
}
35 | P a g e
Panel centerpanel = new Panel();
Panel centertopflowpanel = new Panel();
centertopflowpanel.setLayout(new BorderLayout());
centerpanel.setLayout(new BorderLayout());
sub = new JLabel();
sub.setFont(bold);
centertopflowpanel.add(sub,BorderLayout.CENTER);
reply = new JButton("Reply");
reply.addActionListener(this);
centertopflowpanel.add(reply,BorderLayout.EAST);
centerpanel.add(centertopflowpanel,BorderLayout.NORTH);
centerpanel.add(showMsg,BorderLayout.CENTER);
date = new JLabel();
centerpanel.add(date,BorderLayout.SOUTH);
panInb.add(centerpanel,BorderLayout.CENTER);
} catch(Exception e) {
//Registration.showErrMes("Inbox Error"+e);
System.out.print("Inbox Error"+e);
}
}
// Panel Compose
void addOutPane() {
panCom = new Panel();
panCom.setLayout(null);
36 | P a g e
cmdClear = new JButton("Clear");
cmdClear.setBounds(400,450,100,25);
cmdClear.addActionListener(this);
panCom.add("Center",cmdClear);
if (ae.getSource()==inbox)
{
panBot.setVisible(false);
panBot.removeAll();
addInPane();
panBot.add(panInb);
panBot.setVisible(true);
setVisible(true);
new Notif().setChecked(unm);
}
else if (ae.getSource() == com)
{panBot.setVisible(false);
panBot.removeAll();
addOutPane();
panBot.add(panCom);
panBot.setVisible(true);
setVisible(true);
}
else if(ae.getSource()==back)
{
panBot.setVisible(false);
panBot.removeAll();
setVisible(false);
MenuWin i = new MenuWin(unm);
i.setLocation(0,0);
i.setSize(800,600);
i.setVisible(true);
}
else if (ae.getSource()==lout)
{
panBot.setVisible(false);
panBot.removeAll();
setVisible(false);
Portal p = new Portal();
//p.setSize(640,480);
p.setResizable(false);
p.pack();
p.setLocationByPlatform(true);
p.setVisible(true);
}
37 | P a g e
else if (ae.getSource()==cmdSend)
{
panBot.setVisible(false);
panBot.removeAll();
try {
String mt,su,me;
java.util.Date dt = new java.util.Date();
mt = txtTo.getText();
su = txtSub.getText();
me = txtMes.getText();
ps = con.prepareStatement("insert into mail_details values(?,?,?,?,?)");
ps.setString(1,email);
ps.setString(2,mt);
ps.setString(3,String.valueOf(dt));
ps.setString(4,su);
ps.setString(5,me);
ps.execute();
String recipient = new DBase().getUserId(mt);
new Notif().setNotChecked(recipient);
Registration.showErrMes("Acknowledge:","Mail Sent");
} catch(Exception e) {
Registration.showErrMes(e+"");
}
}
else if (ae.getSource()==cmdClear)
{
//txtFrom.setText("");
txtTo.setText("");
txtSub.setText("");
txtMes.setText("");
}
else if(ae.getSource()==reply)
{
if(l.getSelectedIndex() == -1)
{
Registration.showErrMes("Select a Message to reply");
}
else{
String to = l.getSelectedItem();
String resub = "Re: " + sub.getText().substring(9);
panBot.setVisible(false);
panBot.removeAll();
addOutPane();
panBot.add(panCom);
panBot.setVisible(true);
setVisible(true);
txtTo.setText(to);
txtSub.setText(resub);
}
else if (ae.getSource()== showAddr)
{
38 | P a g e
ShowAddr s = new ShowAddr(unm);
s.setLocation(0,0);
s.setSize(800,600);
s.setVisible(true);
}
Editor.java
/**
* To Add NEW eventS
*/
package Classes;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
39 | P a g e
List topic1;
TextArea desc1;
String unm;
Connection con;
PreparedStatement st;
public Editor(String un) {
unm = un;
setTitle("News Editor");
nedt= new JLabel("News Editor");
Font f=new Font("TimesNewRoman",Font.BOLD,15);
nedt.setFont(f);
nedt.setBounds(350,50,100,25);
add(nedt);
setLayout(null);
nid = new JLabel("News Id");
nid.setBounds(250,100,100,25);
add(nid);
topic1=new List(1);
topic1.add("Politics");
topic1.add("Business");
topic1.add("Sports");
topic1.add("Education");
topic1.setBounds(350,160,100,20);
add(topic1);
40 | P a g e
valid1= new JTextField(10);
valid1.setBounds(350,400,100,25);
add(valid1);
connectDB();
addWindowListener(new W());
41 | P a g e
st.setString(4,des);
st.setInt(5,Integer.parseInt(vdt));
st.execute();
Registration.showErrMes("Acknowledge","News Inserted");
nid1.setText("");
date1.setText("");
desc1.setText("");
valid1.setText("");
} catch(Exception e) {
Registration.showErrMes(e+"");
}
}
}
NewsUser.java
/* To display the News for End Users */
package Classes;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class NewsUser extends JFrame implements ActionListener , ItemListener
{
JLabel nedt,ndt,ndesc,valid,valid1;
JButton back;
Choice lstdt;
TextArea desc1;
Connection con;
PreparedStatement pst;
Statement st;
ResultSet rs,rs1;
int yr,mn,dt;
String unm;
public NewsUser(String un)
{
unm = un;
setTitle("News Editor Display");
nedt= new JLabel("News Editor Display");
Font f=new Font("TimesNewRoman",Font.BOLD,15);
42 | P a g e
nedt.setFont(f);
nedt.setBounds(350,50,150,25);
add(nedt);
setLayout(null);
ndt = new JLabel("Date");
ndt.setBounds(200,75,100,25);
add(ndt);
lstdt=new Choice();
lstdt.setBounds(300,75,80,20);
add(lstdt);
lstdt.addItemListener(this);
connectDB();
addWindowListener(new W());
}
public void connectDB()
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:dsn","","");
//Registration.showErrMes("\n Connected");
st = con.createStatement();
String qry = "Select * from news_details";
rs = st.executeQuery(qry);
while (rs.next())
{
String str = rs.getString(2);
int cnt=0;
for (int i=0;i<lstdt.getItemCount();i++) {
if (str.equals(lstdt.getItem(i))) {
cnt++;
}
43 | P a g e
}
if (cnt == 0)
lstdt.addItem(str);
}
}
catch(Exception e)
{
Registration.showErrMes("\n Connection Exception"+e);
//connectDB();
}
}
desc1.setText("");
valid1.setText("");
while (rs1.next()) {
String d2 = rs1.getString(2);
String str1,str2;
int vd;
str1 = rs1.getString(3);
str2 = rs1.getString(4);
vd = rs1.getInt(5);
if (d1.equals(d2)) {
desc1.append("\n");
desc1.append(str1);
desc1.append("\n");
desc1.append(str2);
desc1.append("\n");
valid1.setText(String.valueOf(vd));
}
}
} catch(Exception e) {
Registration.showErrMes(e+"");
}
}
44 | P a g e
}
AddBook.java
/**
* To Add new Addressess in the Address Book
*/
package Classes;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
setLayout(null);
name = new JLabel("Name");
name.setBounds(270,100,100,25);
add(name);
45 | P a g e
addr = new JLabel("Address");
addr.setBounds(270,160,100,25);
add(addr);
mail=new JLabel("E-mail");
mail.setBounds(270,280,100,25);
add(mail);
mail1=new JTextField(10);
mail1.setBounds(370,280,100,25);
add(mail1);
phone1=new JTextField(10);
phone1.setBounds(370,340,100,25);
add(phone1);
ad=new JButton("Add");
ad.setBounds(250,400,100,25);
ad.addActionListener(this);
add(ad);
clr=new JButton("Clear");
clr.setBounds(350,400,100,25);
clr.addActionListener(this);
add(clr);
addWindowListener(new W());
46 | P a g e
}
public void connectDB()
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:dsn");
}
catch(Exception e)
{
Registration.showErrMes("\n Connection Exception");
}
}
}
else if(ae.getSource()==ad)
{
na=name1.getText();
ad1=address.getText();
cy=city1.getText();
em=mail1.getText();
ph=phone1.getText();
for (j=0;j<ph.length();j++)
{
if (ph.charAt(j) <48 || ph.charAt(j)> 57)
pf =false;
}
for (i=0;i<em.length();i++)
{
if (em.charAt(i) == '@')
fs++;
if (em.charAt(i) == '.')
fs++;
}
47 | P a g e
if (fs != 2)
ef = false;
if (pf == true && ef == false)
{
Registration.showErrMes("Error in Input","Incorrect email id");
}
else if (pf==false && ef==true)
{
Registration.showErrMes("Error in Input","Incorrect Phone Number");
}
else if(pf==true && ef==true)
{
try
{
st = con.prepareStatement("insert into addr_book values
(?,?,?,?,?,?)");
st.setString(1,na);
st.setString(2,ad1);
st.setString(3,cy);
st.setString(4,em);
st.setString(5,ph);
st.setString(6, unm);
st.execute();
tf.setSize(100,100);
tf.setLocation(300,250);
JLabel l = new JLabel("Address Added", JLabel.CENTER);
tf.add(l);
tf.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
tf.setVisible(false);
}
});
tf.setVisible(true);
name1.setText("");
address.setText("");
city1.setText("");
mail1.setText("");
phone1.setText("");
}
catch(Exception e)
{
Registration.showErrMes("Alert!",e+"");
}
}
}
else if (ae.getSource()==view)
{
ShowAddr s = new ShowAddr(unm);
s.setLocation(0,0);
s.setSize(800,600);
s.setVisible(true);
}
48 | P a g e
class W extends WindowAdapter {
public void windowClosing(WindowEvent we) {
setVisible(false);
MenuWin m = new MenuWin(unm);
m.setLocation(0,0);
m.setSize(800,600);
m.setVisible(true);
}
}
}
ShowAddr.java
/* To display the News */
package Classes;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
l = new JLabel[20][5];
addb.setBounds(320,50,100,25);
addb.setFont(f);
pTop.add(addb);
pMid.setLayout(new GridLayout(20,5));
for (int i=0;i<20;i++) {
for (int j=0;j<5;j++) {
l[i][j] = new JLabel("",JLabel.CENTER);
pMid.add(l[i][j]);
}
49 | P a g e
}
l[0][0].setText("Name");
l[0][1].setText("Address");
l[0][2].setText("City");
l[0][3].setText("Email");
l[0][4].setText("Phone");
f=new Font("TimesNewRoman",Font.BOLD,14);
for(int i=0;i<5;i++)
l[0][i].setFont(f);
back = new JButton("Back");
back.setBounds(300,350,100,25);
back.addActionListener(this);
pBot.add(back);
connectDB();
add("North",pTop);
add("Center",pMid);
add("South",pBot);
connectDB();
addWindowListener(new W());
}
public void connectDB()
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:dsn","","");
//Registration.showErrMes("\n Connected");
st = con.createStatement();
rs = st.executeQuery("select * from addr_book");
int i=1;
String s1,s2,s3,s4,s5;
while (rs.next()) {
if(rs.getString(6).equals(unm)) {
s1 = rs.getString(1);
s2 = rs.getString(2);
s3 = rs.getString(3);
s4 = rs.getString(4);
s5 = rs.getString(5);
l[i][0].setText(s1);
l[i][1].setText(s2);
l[i][2].setText(s3);
l[i][3].setText(s4);
l[i][4].setText(s5);
i++;
}
}
} catch(Exception e) {
Registration.showErrMes("\n Connection Exception");
//connectDB();
}
}
50 | P a g e
public void actionPerformed(ActionEvent ae)
{
final Frame tf = new Frame("Acknowledge");
int j,fs=0,i;
boolean ef,pf;
ef=pf=true;
String na,ad1,cy,em,ph;
if (ae.getSource() == back)
{
setVisible(false);
}
}
51 | P a g e
SCREEN
LAYOUTS
52 | P a g e
LOGIN PORTAL
REGISTRATION FORM
53 | P a g e
ADMIN’S MAIN MENU
54 | P a g e
ENDUSER’S MAIN MENU
55 | P a g e
MAIL INBOX
Mail Compose
56 | P a g e
Admin’s News Editor
57 | P a g e
AddressBook
AddressBook – View
58 | P a g e
CONCLUSION
The “INTRANET MAILING SYSTEM” project was designed in a
user-friendly manner specifically to meet the needs of Up and Down
communication in an Organization. The user need not remember the
mail address of others as they can refer using the address book. The
new mail popup also helps to notify the user whether to check inbox or
not. Since Java is an Object Oriented Platform, we can change (or)
modify any activities in the future. This project is flexible to add new
aspects.
59 | P a g e
BIBLIOGRAPHY
SOFTWARE ENGINEERING
RICHARD FAIRLEY
60 | P a g e