Wednesday, 14 October 2015

how to get location of end user by useing JQUERY?

Here i use GeoLite Data base.
In program i use a cdn to get location.
This program return JSON Object which Contain location releted information.


       

<pre class="lang:js"><script type="text/javascript" src="https://js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js"></script>
 
<script type="text/javascript">
 
var onSuccess = function(location){
  alert(
      "Lookup successful:\n\n"
      + JSON.stringify(location, undefined, 4)
  );
  alert( JSON.stringify(location));
};
 
var onError = function(error){
  alert(
      "Error:\n\n"
      + JSON.stringify(error, undefined, 4)
  );
};
 
geoip2.city(onSuccess, onError);
 
</script></pre>
 

Thursday, 1 October 2015

How to receive Mail from Gmail in java ?

import com.jscape.inet.email.EmailMessage;
import com.jscape.inet.popssl.PopSsl;

public class SecurePOPMail {

   public static void main(String[] args) {
   
   
   // and other services will be similar.
      String hostname = "pop.gmail.com";
      String username = "sky33616@gmail.com";   // These lines are your Gmail or Hotmail login
      String password = "XXXXXXXXXX";//Your Password 

   String msgSubject; // Various parts of an EmailMessage
   String msgFrom;
   String msgTo;
   String msgDate;
   String msgBody;
   // Other receivers of this message. "CC" is "carbon copy", if you didn't know, and 
   // "BCC" is "blind carbon copy". When was the last time you saw carbon paper?
   String msgCC; 
   String msgBCC;
   
      try {
         // Create new PopSsl instance and establish the connection to the POP3 server. "995" is 
   // the port number and triggers "implicit" SSL/TLS encryption for the whole message.
         PopSsl ssl = new PopSsl(hostname, 995, username, password);
         ssl.setDebug(true);
         ssl.connect();

         // Get the message count, then print selected parts of each message.
         int count = ssl.getMessageCount();
         for(int i = 1; i <= count; ++i) {
            // Create an EmailMessage instance, then get all the parts separately.
   EmailMessage msg = ssl.getMessage(i);
   msgSubject = msg.getSubject();
   msgFrom = msg.getFrom();
   msgTo = msg.getTo();
   msgDate = msg.getDate();
   msgBody = msg.getBody();
   msgCC = msg.getCc();
   msgBCC = msg.getBcc();

   // This is just to show that you can manipulate message parts. If the
   // Subject includes the word "work", don't print it, because
   // it's sure to be trouble for somebody!
   if (msgSubject.indexOf("work") <= 0) {
    System.out.println("Subject: " + msg.getSubject()); 
   } else {
    System.out.println("Subject: [You don't want to know]");
   }
   
   // Now print the message parts.
   System.out.println("------------------------");
   System.out.println("From: " + msg.getFrom());
   System.out.println("Date: " + msg.getDate());
   System.out.println("CC: " + msg.getCc());
   System.out.println("BCC: " + msg.getBcc());
   System.out.println("Body: " + msg.getBody());
   System.out.println("------------------------");
         }

         // Disconnect
         ssl.disconnect();     
      } catch(Exception e) {
         e.printStackTrace();
      }
   }
}

Download sinetfactory.jar from here

Set it on Your Classpath

Compile it & Run it As JAVA className