Search

Girish Kumar Shakya

Personal Blog

Category

Uncategorized

Android Programming & Social Plugins

Free coupons are available “Android Programming and Social Plugins”

 

courseimagejpeg

 

Regards

mysignature

Girish Kumar Shakya

Advertisements

New Course: Android Programming on Social Plugin

Hi,
Friends, soon going to publish my new course on “Android Programming on Social Plugins” .
In this course programmer will learn to integrate social plugins buttons like Facebook, Google Plus, Twitter and Digits, with bonus chapters on Crashlytics and MobPub(to earn revenue with Ad).
request me for coupon at following link : https://girishkumarshakya.wordpress.com/requestcoupon/​​
To learn more about Android Programming, you can also join my course
Android Application Programming : Build 20+ Android App  at Just 10$,
use coupon code : DEC2015​
Thanks and Regards
Girish Kumar Shakya

OFFER OF THE DAY : GET JAVA CERTIFIED AT JUST 10$

“Java Programming from Scratch” will gives you a complete overview on Java Programming. Java is a general – purpose computer programming language that is concurrent, class-based,object-oriented and platform independent language. Java is everywhere from small devices to Smart phones like Android,Blackberry and has highest paying jobs for Java developers in programming Industry.

discountButton

Certification : Android Advance Programming II

100% Discount for 1 Day Only

Get Certified with Advance Android Programming Level II , and learn advance concept to create Android Application from scratch. In this course you will learn how to convert your imagination into programming. you will learn key concept first in Java and then will learn Complete Android Programming with 15+ projects. All the essential topic is covered in this course with full detail.

click Link to Join

http://lavit.online/course/?courseid=advanceandroid

SELF – PACED :ANDROID APP DEVELOPMENT CERTIFICATION TRAINING

certificationCoin

AndroidProgrammingFreeCourse

Lavit Online Training : How to grasp most from self-paced

Join me on Blab for discussing How to have most from Self – Paced learning

blabselfpaced

Send Mail Using Java Mail API

java-mail-send-01 Sending mail using JavaMail API is quite easy in Java application, if you are creating console based, desktop or web based Java application, JavaMail API is very easy to integrate and help you to send not only text but also Hyper Text messages.

To work with JavaMail API you will need to download javamail-1.4.7  zipped file, after extracting it you will need following files in your java project library.

  • mail.jar
  • dsn.jar
  • gimap.jar
  • imap.jar
  • mailapi.jar
  • pop3.jar
  • smtp.jar

Now, lets create a simple class SendMail.java

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
/**
*
* @author girish
*/
public class SendMail {
private String username;
private String password;
private String to;
private String msg;
private String subject;

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getTo() {
return to;
}

public void setTo(String to) {
this.to = to;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}

public String getSubject() {
return subject;
}

public void setSubject(String subject) {
this.subject = subject;
}

public void send_mail() throws MessagingException{
Properties props = new Properties();//create an instance of properties
props.put(“mail.smtp.auth”, “true”); // set smtp to true
props.put(“mail.smtp.starttls.enable”, “true”);// enables starttls
props.put(“mail.smtp.host”, “smtp.gmail.com”);// add a host name, here i am using                                                                                                //gmail
props.put(“mail.smtp.port”, “587”);// smtp port for gmail is 587

// create Session instance from getInstance() static method

                   Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});

// create message instance using MimeMessage(session)
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(username));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to));// set the recipient to
message.setSubject(subject);//set the subject
//message.setText(msg);// this is commented if you enable you can only send text                                                              message
message.setContent(msg,”text/html”);// setContent method is used to send HTML                                                                                   //formated messages
Transport.send(message);// Using static send() method of Transport class

System.out.println(“Done”);

}

public static void main(String args[]){//main method

SendMail sm=new SendMail();
sm.setUsername(“<your gmail username>”);
sm.setPassword(“<your gmail password>”);

sm.setMsg(“Testing message for JavaMail API”);
sm.setSubject(“LAVIT : ONLINE PROGRAMMING TRAINING ACADEMY”);
sm.setTo(“clairvoyant.1947@gmail.com”);

try {
sm.send_mail();
System.out.println(“Mail send successfully!!”);
} catch (MessagingException ex) {
System.out.println(“ERROR SENDING “+ex.getMessage());
}
}//end of main method
}//end of class

Keep in mind using

message.setText(msg); // used to send simple text message
message.setContent(msg,”text/html”);//used to send message embedded with HTML Tag

now you can use this complete class with any of other project , this will helpful for any type of Java Application

Thanks and Regards

Girish

Founder, Lavit Online Training Academy

for more visit : LAVIT ONLINE TRAINING ACADEMY  

TRY IT and ENJOY

Java APIs for XML Registries

jaxr

JAXR_NEW

For more Join Lavit Online Training Academy

javaprogramming

Blog at WordPress.com.

Up ↑

%d bloggers like this: