Ivan Maurits. Untuk mengirim email menggunakan java anda harus memiliki JavaMail API dan Java Activation Framework (JAF) yang telah terinstall dalam komputer.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

JSP -exercises- Alessandro Marchetto Fondazione Bruno Kessler-IRST, Centro per la Ricerca Scientifica e Tecnologica.
The Internet 8th Edition Tutorial 3 Using Web-Based Services for Communication and Collaboration.
AO- 2 (part 2 of 2) Pass + Send. Receive. Reply. Forward. With more than 1 attachment.
.  The sender and recipient(s) of an message do not have to be online at the same time. When one person sends a message, it is stored on an.
Remote method invocation. Introduction First introduced in JDK 1.1. Allows distributed Java programs to work with each others by behaving as if they are.
1 Servlets Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun.
Java Server Pages (JSP)
Topic : JavaMail API (1) Sending and Receiving s Kaster Nurmukan.
. How it works? To send an you need an Software or Web Based To send an to a friend you need to know their Address.
Application Layer Pertemuan 25 Matakuliah: H0484/Jaringan Komputer Tahun: 2007.
Writing Simple Clients in Java Using Sockets using the JavaMail API.
J2EE JavaMail API Presented by Bartosz Sakowicz. Instalation Java Mail API: Java Activation Framework.
TCP/IP Protocol Suite 1 Chapter 20 Upon completion you will be able to: Electronic Mail: SMTP, POP, and IMAP Understand four configurations of architecture.
JavaMail JavaMail Classes Sending a Message Using JavaMail (MessageSend.java) Sending a Message to Multiple Recipients (SendToMany.java) Installing JavaMail.
CS 580 Client-Server Programming Spring Semester, 2006 Doc 20 Sending Apr 13, 2006 Copyright ©, All rights reserved SDSU & Roger Whitney, 5500.
Java Training Introduction to Java Mail Written by Jeff Smith.
Technion – Israel Institute of Technology Department of Electrical Engineering Software Lab Remote Mailbox based on.NET technology Michael and Eugene Shamis.
CSCI 6962: Server-side Design and Programming Server Created .
Introduction 1 Lecture 7 Application Layer (FTP, ) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer Science & Engineering.
File Upload Instructions and Information The File Upload utility is used for transferring files too large to send through the system. How it Works:
1 JavaMail (1) Presented by: Ke Duan Instructor: Dr. V. “Juggy” Jagannathan.
JAVA MAIL API. High level representation of the basic components of any mail system. The components are represented by abstract classes in the javax.mail.
Sending and Receiving s
Apache Commons Simplifying the Java Mail API Siegfried Goeschl.
Introduction 1-1 Chapter 2 FTP & Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 IC322 Fall.
WEBPAGE DESIGN Electronic Mail Anatomy of an Message Messages Contain Two Parts: HHeader AAddressing information To From Subject MMessage.
English Comprehension and Composition – Lecture 25 Objectives: What is an ? Basics of an Tips for Writing Effective s.
Internet Protocols & Client Server Programming
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
BRIDGE COURSE of INFORMATION & COMMUNICATION TECHNOLOGY
Electronic Mail Originally –Memo sent from one user to another Now –Memo sent to one or more mailboxes Mailbox –Destination point for messages.
Sending Topic 4, Chapters 9, 10 Network Programming Kansas State University at Salina.
1 Using Messages sent from machine to machine and stored for later reading. You will use a client to read –Type mail or pine in UNIX to read.
What is and How Does it Work?  Electronic mail ( ) is the most popular use of the Internet. It is a fast and inexpensive way of sending messages.
File Transfer Protocol (FTP)
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
Remote programs and commands In this presentation… –rpc concepts –rpc connections –rpc actions.
EVON TAN KA VUN THECLA JOSEPH NOR FAEEZA ISMALI JESSICCA TOKIROI.
Topic : JavaMail API Kaster Nurmukan. Overview of JavaMail API Javax.mail.Session Javax.mail.Authenticator and PasswordAuthentication Javax.mail.Message.
Basic Features and Options Accessing  Means of communicating electronically via the Internet.  Used by individuals, businesses,
Lesson No:14 Surfing on Website, Searching, Send/Receive CHBT-01 Basic Micro process & Computer Operation.
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
The Internet 8th Edition Tutorial 3 Using Web-Based Services for Communication and Collaboration.
CS 3830 Day 9 Introduction 1-1. Announcements r Quiz #2 this Friday r Demo prog1 and prog2 together starting this Wednesday 2: Application Layer 2.
XP New Perspectives on The Internet, Sixth Edition— Comprehensive Tutorial 2 1 Evaluating an Program and a Web-Based Service Basic Communication.
  is a system of electronic communication that allows the user to exchange messages over the internet  Everyone’s address is unique  Two.
and the business environment Explain what is and how is it used in a business environment A02 .
A Quick Look At How Works Understanding the basics of how works can make life a lot easier for any user. Especially those who are interested.
(Electronic Mail) a message sent and received electronically via telecommunication links between computers.
Amanda Fristy Damara Thea Bayu Gerhana Yuda Evita Fitri Ila Uswatun Hasanah Putri Ayuning Kartika Presented by :
RYAN HICKLING. WHAT IS AN An messages distributed by electronic means from one computer user to one or more recipients via a network.
CITA 310 Section 6 Providing Services (Textbook Chapter 8)
Slides based on Carey Williamson’s: FTP & SMTP1 File Transfer Protocol (FTP) r FTP client contacts FTP server at port 21, specifying TCP as transport protocol.
CS520 Web Programming Bits and Pieces of Web Programming (II) Chengyu Sun California State University, Los Angeles.
درس مهندسی اینترنت – مهدی عمادی مهندسی اینترنت برنامه‌نویسی در اینترنت 1 SMTP, FTP.
Network Programming 10- SMTP-POP3
JavaMail Electronic Mail Concepts JavaMail Classes
Mail Merge for Lotus Notes and Excel User Guide
Mail Merge for Lotus Notes and Excel User Guide
Using Mail Merge for Lotus Notes
CIW Lesson 7 Part A Name: _______________________________________
Call Outlook customer support toll free number Ireland.
(Includes setup) FAQ ON DOCUMENTS (Includes setup)
An Overview.
Name : __Sajid Ali VU-ID :__ DS
ICT Communications Lesson 5: Communicating Using
(Includes setup) FAQ ON DOCUMENTS (Includes setup)
Simplifying the Java Mail API
Presentation transcript:

Ivan Maurits

Untuk mengirim menggunakan java anda harus memiliki JavaMail API dan Java Activation Framework (JAF) yang telah terinstall dalam komputer   gow/jaf.html gow/jaf.html

Download dan unzip file tersebut, setelah kedua file tersebut di unzip maka akan muncul direktory baru. Tambahkan mail.jar dan activation.jar kedalam CLASSPATH

 Asumsi disini bahwa localhost terkoneksi dengan internet.

// File Name Send .java import java.util.*; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class Send { public static void main(String [] args) { // Recipient's ID needs to be mentioned. String to = // Sender's ID needs to be mentioned String from = // Assuming you are sending from localhost String host = "localhost"; // Get system properties Properties properties = System.getProperties();

// Setup mail server properties.setProperty("mail.smtp.host", host); // Get the default Session object. Session session = Session.getDefaultInstance(properties); try{ // Create a default MimeMessage object. MimeMessage message = new MimeMessage(session); // Set From: header field of the header. message.setFrom(new InternetAddress(from)); // Set To: header field of the header. message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

// Set Subject: header field message.setSubject("This is the Subject Line!"); // Now set the actual message message.setText("This is actual message"); // Send message Transport.send(message); System.out.println("Sent message successfully...."); }catch (MessagingException mex) { mex.printStackTrace(); }

$ java Send Sent message successfully....

void addRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException Parameter :  type: Harus di set TO, CC or BCC.  addresses: Array ID. Dibutuhkan InternetAddress() method ketika menentukan IDs

 Here is an example to send an HTML from your machine. Here it is assumed that your localhostis connected to the internet and capable enough to send an .  This example is very similar to previous one, except here we are using setContent() method to set content whose second argument is "text/html" to specify that the HTML content is included in the message.  Using this example, you can send as big as HTML content you like.

// File Name SendHTML .java import java.util.*; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class SendHTML { public static void main(String [] args) { // Recipient's ID needs to be mentioned. String to = // Sender's ID needs to be mentioned String from =

// Assuming you are sending from localhost String host = "localhost"; // Get system properties Properties properties = System.getProperties(); // Setup mail server properties.setProperty("mail.smtp.host", host); // Get the default Session object. Session session = Session.getDefaultInstance(properties); try{ // Create a default MimeMessage object. MimeMessage message = new MimeMessage(session); // Set From: header field of the header. message.setFrom(new InternetAddress(from)); // Set To: header field of the header. message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

// Set Subject: header field message.setSubject("This is the Subject Line!"); // Create the message part BodyPart messageBodyPart = new MimeBodyPart(); // Fill the message messageBodyPart.setText("This is message body"); // Create a multipar message Multipart multipart = new MimeMultipart(); // Set text message part multipart.addBodyPart(messageBodyPart);

// Part two is attachment messageBodyPart = new MimeBodyPart(); String filename = "file.txt"; DataSource source = new FileDataSource(filename); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename); multipart.addBodyPart(messageBodyPart); // Send the complete message parts message.setContent(multipart ); // Send message Transport.send(message); System.out.println("Sent message successfully...."); }catch (MessagingException mex) { mex.printStackTrace(); }

$ java SendFile Sent message successfully....

 Jika dibutuhkan User ID dan password pada server. Gunakan properties sbb : props.setProperty("mail.user", "myuser"); props.setProperty("mail.password", "mypwd");