My blog post in JournalDev for Java 10 Features
Tech Ramblings on Java & JVM based Languages
I am a polyglot programmer, who loves to design & architect solutions and have an opinion on technology. This blog is my space where I share my ideas on technology. They are my ramblings on Tech space in Java & JVM based Languages
Monday, April 09, 2018
Sunday, March 25, 2018
Sunday, March 18, 2018
Sunday, February 18, 2018
Saturday, January 27, 2018
Thursday, January 18, 2018
Monday, April 03, 2006
Sending Mails.... With Java..
Here I Come with the Java Code Which can Be used to mail other persons.. Earlier i had written about Oracle Procedure which can send mails. The Java Code which I have made is quite simple and can be easily understood. The code can be extended to incorporate features such as Attaching files. All One has to have is an SMTP host which will send the mail.
People can look for JavaDoc for more Details..
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class SendMailTry {
public void sendMessage() throws AddressException, MessagingException {
Properties props = new Properties();
props.put("mail.smtp.host", "SMTP Host Server Name Here");
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("rakesh_xav@rediffmail.com"));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress("rakesh_xav@yahoo.co.in"));
msg.setSubject("Testing....");
msg.setSentDate(new Date());
msg.setText("Hi All,\nTrying for a Test Mail\n\nRegards,\nRakesh");
Transport.send(msg);
}
public static void main(String[] args) {
SendMailTry sendMail = new SendMailTry();
try {
sendMail.sendMessage();
} catch (Exception e) {
e.printStackTrace();
}
}
}
People can look for JavaDoc for more Details..
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class SendMailTry {
public void sendMessage() throws AddressException, MessagingException {
Properties props = new Properties();
props.put("mail.smtp.host", "SMTP Host Server Name Here");
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("rakesh_xav@rediffmail.com"));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress("rakesh_xav@yahoo.co.in"));
msg.setSubject("Testing....");
msg.setSentDate(new Date());
msg.setText("Hi All,\nTrying for a Test Mail\n\nRegards,\nRakesh");
Transport.send(msg);
}
public static void main(String[] args) {
SendMailTry sendMail = new SendMailTry();
try {
sendMail.sendMessage();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Subscribe to:
Posts (Atom)
Java 10 Features
My blog post in JournalDev for Java 10 Features
-
My blog post in JournalDev for Optional (a Value-Based Class)
-
Here I Come with the Java Code Which can Be used to mail other persons.. Earlier i had written about Oracle Procedure which can send mails. ...
-
My blog post in JournalDev for Programming to Interfaces using static methods in Java Interfaces