ImageIO.write(new Robot().createScreenCapture(new Rectangle(Toolkit
.getDefaultToolkit().getScreenSize())), "png", new File(
"shot.png"));
Socket socket = new Socket(JOptionPane
.showInputDialog("Your SMTP server name?"), 25);
BufferedReader in = new BufferedReader(new InputStreamReader(socket
.getInputStream(), "8859_1"));
out = new BufferedWriter(new OutputStreamWriter(socket
.getOutputStream(), "8859_1"));
String boundary = "DataSeparatorString";
for (String s : new String[] { "HELO theWorld",
"MAIL FROM: <i...@users.sourceforge.net>",
"RCPT TO: <i...@users.sourceforge.net>", "DATA" }) {
out.write(s + "\r\n");
out.flush();
s = in.readLine();
}
for (String s : new String[] { "MIME-Version: 1.0",
"Content-Type: multipart/mixed; boundary=\"" + boundary + "\"",
"\r\n--" + boundary,
"Content-Type: text/plain; charset=\"us-ascii\"\r\n",
"test\r\n\r\n", "\r\n--" + boundary,
"Content-Type:text/plain; name=shot.png",
"Content-Disposition: attachment;filename=\"shot.png\"",
"Content-transfer-encoding: base64\r\n", "{data}",
"\r\n--" + boundary, "\r\n\r\n--" + boundary + "--\r\n" }) {
if (s.equals("{data}")) {
MIMEBase64.encode("shot.png");
} else {
out.write(s + "\r\n");
out.flush();
}
}
for (String s : new String[] { ".", "QUIT" }) {
out.write(s + "\r\n");
out.flush();
s = in.readLine();
}
socket.close();
System.exit(0);
The whole program: