Wednesday, November 10, 2010

Accessing Gmail SMTP through JAVA

import java.util.Properties;

import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.search.FlagTerm;


public class GmailTest {

private static final String SMTP_HOST_NAME = "smtp.gmail.com";
private static final int SMTP_HOST_PORT = 465;
private static final String SMTP_AUTH_USER = "gmailid";
private static final String SMTP_AUTH_PWD = "password";

public static void main(String[] args) throws Exception{
new GmailTest().test();
}
public void test() throws Exception{
Properties props = new Properties();

props.put("mail.transport.protocol", "smtps");
props.put("mail.smtps.host", SMTP_HOST_NAME);
props.put("mail.smtps.auth", "true");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", SMTP_AUTH_USER, SMTP_AUTH_PWD);
FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_ONLY);
Message messages[] = inbox.search(ft);
for(Message message1:messages) {
System.out.println(message1.getAllHeaders().nextElement());
}
}
}

Monday, January 18, 2010

Date and Time code (Date & Time will change dynamically based on system time)

place below code - inside the script tags

function startTime(){
//To print the Month/Date
var now=new Date();
var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
document.getElementById('ciDate').innerHTML = monthname[now.getMonth()] + " " + now.getDate();

var today=new Date();
var h=today.getHours()
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10 m=checkTime(m); s=checkTime(s); document.getElementById('gmtTime').innerHTML = h+":"+m+":"+s; t=setTimeout('startTime()',500); } function checkTime(i){ if (i<10){ i = "0" + i; } return i; }


onload call the startTime() (java script method)

place below code in inside body tags

Date: open span tag id="ciDate" close span tag, Time : open span id="gmtTime" end span tag.



Out put : Date: Jan 19 Time : 12:12:50 (Time will change dynamically)

Tuesday, January 5, 2010

Copy and paste the files/text/graphics (Clipboard) content between remote desktop session and local computer in Windows XP.

1) TaskManager -> Process - check whether rdpclip.exe running or not.

2) if rdpclip.exe runs -> kill the service and start again ( new task -> rdpclip.exe -> ok)
else -> start the rdpclip.exe (new task -> rdpclip.exe -> ok)
:-)