import javax.mail.*;
import javax.mail.internet.*;
import java.net.InetAddress;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.activation.*;
SendMail2(){
this.add(l1);
this.add(to);
this.add(l2);
this.add(from);
this.add(l3);
this.add(subject);
this.add(l4);
this.add(content);
this.add(l5);
this.add(attchments);
this.add(b1);
this.add(res);
to.addActionListener(this);
to.
setBackground(new Color(90,
45,
30));
to.
setForeground(Color.
white);
from.addActionListener(this);
from.
setBackground(new Color(90,
45,
30));
from.
setForeground(Color.
white);
subject.addActionListener(this);
subject.
setBackground(new Color(90,
45,
30));
subject.
setForeground(Color.
white);
attchments.addActionListener(this);
attchments.
setBackground(new Color(90,
45,
30));
attchments.
setForeground(Color.
white);
res.addActionListener(this);
res.
setBackground(new Color(90,
45,
30));
res.
setForeground(Color.
white);
content.setFont(f1);
content.
setForeground(Color.
red);
content.
setBackground(Color.
black);
b1.
setBackground(Color.
green);
b1.
setForeground(Color.
red);
b1.addActionListener(this);
{
{
}
});
}
{
try{
String mailer
= "MyMailerProgram";
props.put("mail.smtp.host", ogms);
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from.getText()));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to.getText(), false));
msg.setSubject(subject.getText());
msg.setHeader("X-Mailer", mailer);
//msg.setText(content.getText());
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(content.getText());
MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds= new FileDataSource(attchments.getText());
mbp2.setDataHandler( new DataHandler(fds));
mbp2.setFileName(attchments.getText());
MimeMultipart mp;
mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp);
Transport.send(msg);
res.setText("You'r Mail Successfully Sent");
repaint();
}
}
}
{
setBackground
(new Color(50,
50,
70));
}
public static void main
(String[] argv
)
SendMail2 s = new SendMail2();
s.setSize(250,450);
s.setTitle("www.srinumail.com");
s.show();
}
}
set CLASSPATH=%CLASSPATH%;activation.jar;mail.jar
So I am able to compile but...It is not working ...
Require more usage instructions